UserModel.cs
6.17 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using AIAHTML5.ADMIN.API.Entity;
namespace AIAHTML5.ADMIN.API.Models
{
public class UserModel
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string EmailId { get; set; }
public string LoginId { get; set; }
public string NewLoginId { get; set; }
public string Password { get; set; }
public int SecurityQuestionId { get; set; }
public string SecurityAnswer { get; set; }
public int CreatorId { get; set; }
public DateTime CreationDate { get; set; }
public DateTime DeactivationDate { get; set; }
public int ModifierId { get; set; }
public DateTime ModifiedDate { get; set; }
public int UserTypeId { get; set; }
public bool IsActive { get; set; }
public int LicenseId { get; set; }
public int EditionId { get; set; }
public short iUserTypeId { get; set; }
public int InGroup { get; set; }
public string ProductEdition { get; set; }
public static bool UpdateUserProfile(AIADatabaseV5Entities dbContext, int intUserID, string strFirstName, string strLastName, string strEmailID)
{
var spStatus = new System.Data.Objects.ObjectParameter("Status", 0);
try
{
dbContext.UpdateUserProfile(intUserID, strFirstName, strLastName, strEmailID, spStatus);
if (spStatus.Value.ToString() == "1")
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
return false;
}
}
public static bool UpdateUserPassword(AIADatabaseV5Entities dbContext, int intUserID, string newPassword)
{
var spStatus = new System.Data.Objects.ObjectParameter("Status", 0);
try
{
dbContext.UpdateAiaUserPassword(intUserID, newPassword, spStatus);
return (bool)spStatus.Value;
}
catch (Exception ex)
{
return false;
}
}
public static string UpdateUserId(AIADatabaseV5Entities dbContext, int id, string userId, string oldUserId)
{
var spStatus = new System.Data.Objects.ObjectParameter("Status", 0);
try
{
dbContext.usp_UpdateUserId(id, userId, oldUserId, spStatus);
if (spStatus.Value.ToString() == "1")
{
// return "success";
return "1";
}
else if (spStatus.Value.ToString() == "2")
{
return "2";
// return "Already Exist Userid";
}
else
{
return "fail";
}
}
catch (Exception ex)
{
return ex.Message;
}
}
public static string InsertUser(AIADatabaseV5Entities dbContext,UserModel UserEntity)
{
var spStatus = new System.Data.Objects.ObjectParameter("Status", 0);
short questionId = 0;
short EditionId=(short) UserEntity.EditionId;
try
{
dbContext.usp_InsertAIAUser(UserEntity.LoginId, UserEntity.Password, UserEntity.FirstName, UserEntity.LastName, (byte)UserEntity.iUserTypeId, UserEntity.EmailId, (byte)questionId, null, UserEntity.Id, UserEntity.LicenseId, (byte)EditionId, spStatus);
return spStatus.Value.ToString();
}
catch(Exception ex)
{
return ex.Message;
}
}
public static string UpdateUser(AIADatabaseV5Entities dbContext, UserModel UserEntity)
{
var spStatus = new System.Data.Objects.ObjectParameter("Status", 0);
short questionId = 0;
short EditionId = (short)UserEntity.EditionId;
try
{
dbContext.usp_UpdateAIAUser(UserEntity.LoginId, UserEntity.Password, UserEntity.FirstName, UserEntity.LastName,UserEntity.EmailId,UserEntity.Id,UserEntity.CreatorId,(UserEntity.IsActive ? (byte)1 :(byte)0),spStatus);
return spStatus.Value.ToString();
}
catch (Exception ex)
{
return ex.Message;
}
}
public static bool UpdateUnblockedUser(AIADatabaseV5Entities dbContext, List<int> ids)
{
var spStatus = new System.Data.Objects.ObjectParameter("Status", 0);
try
{
foreach (var item in ids)
{
dbContext.usp_UpdateblockedUser(item, spStatus);
if (spStatus.Value.ToString()!="1") break;
}
return (spStatus.Value.ToString()=="1"?true:false);
}
catch (Exception ex)
{
return false;
}
}
public static bool InsertDeleteUserManageRight(AIADatabaseV5Entities dbContext, List<int> SelectectedUserRights, List<int> UncheckedUserRights,
int UserId,string RoleName)
{
var spStatus = new System.Data.Objects.ObjectParameter("Status", 0);
try
{
foreach (var item in SelectectedUserRights)
{
dbContext.usp_InsertDeleteUserManageRights(RoleName,item,UserId,"Insert", spStatus);
if (!(bool)spStatus.Value) break;
}
foreach (var item in UncheckedUserRights)
{
dbContext.usp_InsertDeleteUserManageRights(RoleName, item, UserId, "Remove", spStatus);
if (!(bool)spStatus.Value) break;
}
return (bool)spStatus.Value;
}
catch (Exception ex)
{
return false;
}
}
}
}