-
Notifications
You must be signed in to change notification settings - Fork 0
/
AllotmentManager.cs
176 lines (159 loc) · 7.48 KB
/
AllotmentManager.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
using Denial_Coding.BAL.Generics;
using Denial_Coding.BAL.ViewModels;
using DC.DAL;
using Microsoft.Win32.SafeHandles;
using System;
using System.Collections.Generic;
using System.Data;
//using System.Data.Entity;
using System.Data.Entity.Validation;
using System.Data.SqlClient;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
//using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Data.Entity;
using System.Data.Entity.SqlServer;
namespace Denial_Coding.BAL.Managers
{
public class AllotmentManager : IAllotmentService
{
#region Get Practice Names
public List<SelectListItem> GetPracticeList()
{
try
{
using (McKesson_GVLEntities _context = new McKesson_GVLEntities())
{
//ImportModel model = new ImportModel();
string userName = System.Environment.UserName.ToString();
int Project_id = Convert.ToInt32(HttpContext.Current.Session[Constants.ProjectId].ToString());
var list = (from practice in _context.tbl_PRACTICE_MASTER
join project in _context.tbl_PROJECT_MASTER on practice.PROJECT_ID equals project.PROJECT_ID
where project.PROJECT_ID == Project_id
select new SelectListItem
{
Text = practice.PRACTICE,
Value = SqlFunctions.StringConvert((double)practice.PRACTICE_ID).Trim()
}).ToList();
return list;
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region Get Coder Names
public List<SelectListItem> getCoderNames(int tl, int user)
{
try
{
using (McKesson_GVLEntities _context = new McKesson_GVLEntities())
{
int projectId = Convert.ToInt32(HttpContext.Current.Session[Constants.ProjectId]);
string userName = Convert.ToString(HttpContext.Current.Session[Constants.UserName]);
int locationid = Convert.ToInt32(HttpContext.Current.Session[Constants.LocationId]);
var list = (from coder in _context.tbl_USER_ACCESS
where coder.PROJECT_ID == projectId && (coder.ACCESS_ID == tl || coder.ACCESS_ID == user) && coder.LOCATION_ID == locationid && (coder.TL_NTLG == userName || coder.USER_NTLG == userName)
&& coder.LOCATION_ID == locationid
select new SelectListItem
{
Text = coder.USER_NTLG,
Value = SqlFunctions.StringConvert((double)coder.USER_ID).Trim()
}).ToList();
return list;
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region Get AccountDetails
public DataTable GetAccountDetails(string status, string fromDos, string toDos, int practiceId)
{
int Project_id = Convert.ToInt32(HttpContext.Current.Session[Constants.ProjectId].ToString());
string userName = HttpContext.Current.Session[Constants.UserName].ToString();
DataSet dsCommon = new DataSet();
using (McKesson_GVLEntities _context = new McKesson_GVLEntities())
{
//if (HttpContext.Current.Session["CodingAllotment"]==null)
//{
try
{
var access_id = (from use in _context.tbl_USER_ACCESS where use.USER_NTLG == userName select new { use.ACCESS_ID }).Single();
int acc_id = Convert.ToInt32(access_id.ACCESS_ID.ToString());
HttpContext.Current.Session[Constants.AccessID] = acc_id;
dsCommon.Clear();
SqlConnection conObj = new SqlConnection(Constants.ConnectionString);
conObj.Open();
SqlCommand cmdObj = new SqlCommand(Constants.SPCodingAllotment, conObj);
cmdObj.CommandType = CommandType.StoredProcedure;
cmdObj.Parameters.AddWithValue("@Status", status);
cmdObj.Parameters.AddWithValue("@FromDate", fromDos);
cmdObj.Parameters.AddWithValue("@ToDate", toDos);
cmdObj.Parameters.AddWithValue("@Project_Id", Project_id);
cmdObj.Parameters.AddWithValue("@Practice_Id", practiceId);
cmdObj.Parameters.AddWithValue("@USER_NTLG", userName);
cmdObj.Parameters.AddWithValue("@access_id", acc_id);
SqlDataAdapter adapter1 = new SqlDataAdapter(cmdObj);
adapter1.Fill(dsCommon);
conObj.Close();
HttpContext.Current.Session["CodingAllotment"] = dsCommon;
return dsCommon.Tables[0];
}
catch (Exception e)
{
throw e;
//return null;
}
}
}
#endregion
#region AllotToCoder
public void AllotToCoder(string listOfAccounts, string practiceId, string codername)
{
string[] array = listOfAccounts.Split(',').Select(x => x.Trim()).ToArray();
using (McKesson_GVLEntities _context = new McKesson_GVLEntities())
{
int projectId = Convert.ToInt32(HttpContext.Current.Session[Constants.ProjectId]);
string userName = HttpContext.Current.Session[Constants.UserName].ToString();
for (int i = 0; i < array.Length; i++)
{
if (Convert.ToInt32(array[i].ToString()) == 0)
{
}
else
{
_context.USP_Enter_Transaction_List(Convert.ToInt32(practiceId), Convert.ToInt32(array[i].ToString()), userName, codername);
_context.SaveChanges();
}
}
}
}
#endregion
#region UpdateAllotToCoder
public void UpdateAllotToCoder(string listOfAccounts, string practiceId, string codername)
{
string[] array = listOfAccounts.Split(',').Select(x => x.Trim()).ToArray();
using (McKesson_GVLEntities _context = new McKesson_GVLEntities())
{
int projectId = Convert.ToInt32(HttpContext.Current.Session[Constants.ProjectId]);
string userName = HttpContext.Current.Session[Constants.UserName].ToString();
for (int i = 0; i < array.Length; i++)
{
_context.USP_Update_Transaction_List(Convert.ToInt32(practiceId), Convert.ToInt32(array[i].ToString()), userName, codername);
_context.SaveChanges();
}
}
}
#endregion
}
}