private async void registrationButton_MouseClick(object sender, MouseEventArgs e) { if (CheckRegistration()) { try { using (DataBaseIM db = new DataBaseIM()) { UsersLogin user = new UsersLogin(); user.Login = registrationName.Text; user.Password = registrationPassword.Text; user.Mail = registrationMail.Text; db.UsersLogins.Add(user); CustomerInformation userInformation = new CustomerInformation(); userInformation.UserLogin = user; db.CustomersInformations.Add(userInformation); await db.SaveChangesAsync(); } } catch (Exception w) { MessageBox.Show("Error Server: " + w.ToString()); } MessageBox.Show("Account Created!"); loginPanel.Visible = true; registrationPanel.Visible = false; } }
static void Main() { //线程互斥,只允许运行一个应用 bool createNew; using (System.Threading.Mutex m = new System.Threading.Mutex(true, Application.ProductName, out createNew)) { if (createNew) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); UsersLogin frm = new UsersLogin(); try { if (frm.ShowDialog() == DialogResult.OK) { frm.Close(); DDI.Common.BusinessLog.WriteBusinessLog("系统登录" + ":明细信息:\r\n 登录时间" + DateTime.Now.ToString() + "\r\n用户名:" + AppData.LoginName, "系统登录"); Application.Run(new ExecuteOperation()); } } catch (Exception ex) { } } else { MessageBox.Show("应用程序已经启动,请不要重复启动", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
public IActionResult DeleteUser(int UserId) { //string connectionString = configuration.GetSection("ConnectionString").GetSection("DefaultConnection").Value; UsersLogin users = new UsersLogin(); try { int row = Data.Users.DeleteUser(UserId); if (row > 0) { return(StatusCode((int)HttpStatusCode.OK, "Deleted Successfully")); } else { return(StatusCode((int)HttpStatusCode.InternalServerError, new { error = new { message = "Error while Deleting the record" } })); } } catch (Exception e) { string SaveErrorLog = Data.Common.SaveErrorLog("DeleteUser", e.Message.ToString()); return(StatusCode((int)HttpStatusCode.InternalServerError, new { error = new { message = e.Message } })); } }
public IActionResult UpdateVerificationStatus(int UserId, bool Status, RegSource Source) { //string connectionString = configuration.GetSection("ConnectionString").GetSection("DefaultConnection").Value; UsersLogin users = new UsersLogin(); try { if (UserId <= 0 || UserId == null) { return(StatusCode((int)HttpStatusCode.BadRequest, new { error = new { message = "Please enter UserID" } })); } else { int row = Data.Users.UpdateVerificationStatus(UserId, Status, Source.ToString()); if (row > 0) { return(StatusCode((int)HttpStatusCode.OK, "Updated Successfully")); } else { return(StatusCode((int)HttpStatusCode.InternalServerError, new { error = new { message = "Error while Update Phone/Email status" } })); } } } catch (Exception e) { string SaveErrorLog = Data.Common.SaveErrorLog("UpdatePhoneEmailStatus", e.Message.ToString()); return(StatusCode((int)HttpStatusCode.InternalServerError, new { error = new { message = e.Message.ToString() } })); } }
private async void buttonUsersDel_Click(object sender, EventArgs e) { if (dataGridViewUsers.SelectedRows.Count > 0) { int index = dataGridViewUsers.SelectedRows[0].Index; int id = 0; bool converted = Int32.TryParse(dataGridViewUsers[0, index].Value.ToString(), out id); if (converted == false) { return; } UsersLogin user = db.UsersLogins.Find(id); if (user.Admin == true) { MenedjerInformation mInfo = db.MenedjersInformations.FirstOrDefault(mI => mI.UserLoginId == user.Id); if (mInfo != null) { db.MenedjersInformations.Remove(mInfo); } } else { CustomerInformation cInfo = db.CustomersInformations.FirstOrDefault(cI => cI.UserLoginId == user.Id); if (cInfo != null) { db.CustomersInformations.Remove(cInfo); } } db.UsersLogins.Remove(user); await db.SaveChangesAsync(); MessageBox.Show("object deleted"); } }
public ActionResult LoginPage(UsersLogin obj) { string cook = string.Empty; JsonData = CheckDetails(obj); var UserData = JsonConvert.DeserializeObject <IEnumerable <UserData> >(JsonData); foreach (var item in UserData) { Session["UserID"] = item.CName.ToString(); Session["CID"] = item.CID.ToString(); cook = item.Cemail.ToString(); } if (JsonData.Length > 0) { FormsAuthentication.SetAuthCookie(cook, false); return(RedirectToAction("view1", "BookMovie")); } else { return(View()); } return(View()); }
public ActionResult <UsersLogin> storeUL(apiRequest objRequest) { try { //FILL OBJECT USER UsersLogin objUser = new UsersLogin() { Username = objRequest.username, Source = objRequest.source, Ipaddress = Request.HttpContext.Connection.RemoteIpAddress.ToString(), LoginDate = DateTime.Now, }; //STORE DATA IN DATABASE USING ENTITY FRAMEWORK using (var objContext = new SGAContext()) { objContext.UsersLogins.Add(objUser); objContext.SaveChanges(); } //RETURN 200 - OK return(StatusCode(200, objUser)); } catch (Exception Exp) { //RETURN 500 INTERNAL SERVER ERROR AND EXCEPCION return(StatusCode(500, Exp.Message)); } }
public async Task <IActionResult> LoginAsync(UsersLogin user) { AppUser result = await _mediator.Send(user); Response.Cookies.Delete(".AspNetCore.Identity.Application"); return(JsonOf(result)); }
protected void btnInsert_Click(object sender, EventArgs e) { try { usersLogin = new UsersLogin(); teachers = new Teacher(); scDao = new SchoolDao(); string strTeacherLastName = txtLastName.Text; string strTeacherFirstName = txtFirstName.Text; string strTeacherDepartment = txtDepartament.Text; string strUserEmail = inputEmail.Text; string strPassword = inputPassword.Text; teachers.TeacherLastName = strTeacherLastName; teachers.TeacherFirstName = strTeacherFirstName; teachers.TeacherDepartment = strTeacherDepartment; usersLogin.UserEmail = strUserEmail; usersLogin.UserPassword = scDao.CreatePasswordHash(strPassword); scDao.InsetTeachers(teachers, usersLogin); lblMsg.Text = "Teacher Inserted!"; btnInsert.Enabled = false; } catch (Exception ex) { lblMsg.Text = ex.Message.ToString(); } }
public IActionResult GetAllUserList() { //string GetConnectionString = UsersController.GetConnectionString(); //string GetConnectionString = configuration.GetSection("ConnectionString").GetSection("DefaultConnection").Value; List <UsersLogin> userList = new List <UsersLogin>(); try { DataTable dt = Data.Users.GetAllUserList(); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { UsersLogin user = new UsersLogin(); var DecryptPassword = ""; if (dt.Rows[i]["Password"].ToString() != "" || dt.Rows[i]["Password"].ToString() != null) { DecryptPassword = Common.DecryptData(dt.Rows[i]["Password"].ToString()); } else { DecryptPassword = ""; } user.UserId = (int)dt.Rows[i]["UserId"]; user.Email = (dt.Rows[i]["Email"] == DBNull.Value ? "" : dt.Rows[i]["Email"].ToString()); user.Password = DecryptPassword; // (dt.Rows[i]["Password"] == DBNull.Value ? "" : dt.Rows[i]["Password"].ToString()); user.Name = (dt.Rows[i]["Name"] == DBNull.Value ? "" : dt.Rows[i]["Name"].ToString()); user.PhoneNumber = (dt.Rows[i]["PhoneNumber"] == DBNull.Value ? "" : dt.Rows[i]["PhoneNumber"].ToString()); user.SourceofReg = (dt.Rows[i]["SourceofReg"] == DBNull.Value ? "" : dt.Rows[i]["SourceofReg"].ToString()); user.IsPromoCodeApplicable = (dt.Rows[i]["IsPromoCodeApplicable"] == DBNull.Value ? false : (bool)dt.Rows[i]["IsPromoCodeApplicable"]); user.IsEmailVerified = (dt.Rows[i]["IsEmailVerified"] == DBNull.Value ? false : (bool)dt.Rows[i]["IsEmailVerified"]); user.IsPhoneNumVerified = (dt.Rows[i]["IsPhoneNumVerified"] == DBNull.Value ? false : (bool)dt.Rows[i]["IsPhoneNumVerified"]); user.CreatedDate = (dt.Rows[i]["CreatedDate"] == DBNull.Value ? "" : dt.Rows[i]["CreatedDate"].ToString()); user.Role = (dt.Rows[i]["Role"] == DBNull.Value ? "" : dt.Rows[i]["Role"].ToString()); user.VehicleCount = (int)dt.Rows[i]["VehicleCount"]; //user.ModifiedDate = (dt.Rows[i]["ModifiedDate"] == DBNull.Value ? "" : dt.Rows[i]["ModifiedDate"].ToString()); //user.IsDeleted = (dt.Rows[0]["IsDeleted"] == DBNull.Value ? false : (bool)dt.Rows[0]["IsDeleted"]); userList.Add(user); //DecryptPassword = ""; } return(StatusCode((int)HttpStatusCode.OK, userList)); } else { return(StatusCode((int)HttpStatusCode.OK, userList)); } } catch (Exception e) { string SaveErrorLog = Data.Common.SaveErrorLog("Users", e.Message); return(StatusCode((int)HttpStatusCode.InternalServerError, new { error = new { message = e.Message } })); } }
public IActionResult Login([FromBody] Login userlogin) { //string GetConnectionString = UsersController.GetConnectionString(); IActionResult response = Unauthorized(); //var user = AuthenticateUser(login); List <UsersLogin> userList = new List <UsersLogin>(); try { DataTable dt = Data.Users.Login(userlogin); if (dt.Rows.Count > 0) { UsersLogin user = new UsersLogin(); user.UserId = (int)dt.Rows[0]["UserId"]; user.Email = (dt.Rows[0]["Email"] == DBNull.Value ? "" : dt.Rows[0]["Email"].ToString()); user.Name = (dt.Rows[0]["Name"] == DBNull.Value ? "" : dt.Rows[0]["Name"].ToString()); user.PhoneNumber = (dt.Rows[0]["PhoneNumber"] == DBNull.Value ? "" : dt.Rows[0]["PhoneNumber"].ToString()); user.SourceofReg = (dt.Rows[0]["SourceofReg"] == DBNull.Value ? "" : dt.Rows[0]["SourceofReg"].ToString()); user.IsPromoCodeApplicable = (dt.Rows[0]["IsPromoCodeApplicable"] == DBNull.Value ? false : (bool)dt.Rows[0]["IsPromoCodeApplicable"]); user.IsEmailVerified = (dt.Rows[0]["IsEmailVerified"] == DBNull.Value ? false : (bool)dt.Rows[0]["IsEmailVerified"]); user.IsPhoneNumVerified = (dt.Rows[0]["IsPhoneNumVerified"] == DBNull.Value ? false : (bool)dt.Rows[0]["IsPhoneNumVerified"]); user.CreatedDate = (dt.Rows[0]["CreatedDate"] == DBNull.Value ? "" : dt.Rows[0]["CreatedDate"].ToString()); user.Role = (dt.Rows[0]["Role"] == DBNull.Value ? "" : dt.Rows[0]["Role"].ToString()); //user.ModifiedDate = (dt.Rows[0]["ModifiedDate"] == DBNull.Value ? "" : dt.Rows[0]["ModifiedDate"].ToString()); //user.IsDeleted = (dt.Rows[0]["IsDeleted"] == DBNull.Value ? false : (bool)dt.Rows[0]["IsDeleted"]); userList.Add(user); var token = GenerateJSONWebToken(); var encrypt = Common.EncryptData(token); //var decrypt = ss.DecryptData(encrypt); , DecryptedText = decrypt //return StatusCode((int)HttpStatusCode.OK, new { Data = userList, TokenString = tokenstr, EncryptedTokenString = encrypt, Status = "Success" }); return(StatusCode((int)HttpStatusCode.OK, new { user, token })); } else { string SaveErrorLog = Data.Common.SaveErrorLog("Login", "Invalid User"); //return StatusCode((int)HttpStatusCode.Unauthorized, new { Data = "Invalid User" }); return(StatusCode((int)HttpStatusCode.Forbidden, new { error = new { message = "Invalid User" } })); } } catch (Exception e) { string SaveErrorLog = Data.Common.SaveErrorLog("Login", e.Message); //return StatusCode((int)HttpStatusCode.InternalServerError, new { Data = e.Message.ToString() }); return(StatusCode((int)HttpStatusCode.InternalServerError, new { error = new { message = e.Message.ToString() } })); } }
public string CheckDetails(UsersLogin obj) { return(Httpclientcall(obj, "loginUser")); //using (HttpClient client = new HttpClient()) //{ // string stringData = JsonConvert.SerializeObject(obj); // var contentData = new StringContent(stringData, System.Text.Encoding.UTF8, "application/json"); // HttpResponseMessage response = client.PostAsync(webapiurl + "/Register/loginUser", contentData).Result; // var list = response.Content.ReadAsStringAsync().Result; // return list; //} }
public IActionResult Authentication(externalLogin userlogin) { try { List <UsersLogin> userList = new List <UsersLogin>(); DataSet ds = Data.Users.ExternalLogin(userlogin); string row = ds.Tables[0].Rows[0]["ErrorMessage"].ToString(); if (row == "Success") { DataTable dt = ds.Tables[1]; if (dt.Rows.Count > 0) { UsersLogin user = new UsersLogin(); user.UserId = (int)dt.Rows[0]["UserId"]; user.Email = (dt.Rows[0]["Email"] == DBNull.Value ? "" : dt.Rows[0]["Email"].ToString()); user.Name = (dt.Rows[0]["Name"] == DBNull.Value ? "" : dt.Rows[0]["Name"].ToString()); // user.PhoneNumber = (dt.Rows[0]["PhoneNumber"] == DBNull.Value ? "" : dt.Rows[0]["PhoneNumber"].ToString()); user.SourceofReg = (dt.Rows[0]["SourceofReg"] == DBNull.Value ? "" : dt.Rows[0]["SourceofReg"].ToString()); user.IsPromoCodeApplicable = (dt.Rows[0]["IsPromoCodeApplicable"] == DBNull.Value ? false : (bool)dt.Rows[0]["IsPromoCodeApplicable"]); user.IsEmailVerified = (dt.Rows[0]["IsEmailVerified"] == DBNull.Value ? false : (bool)dt.Rows[0]["IsEmailVerified"]); user.IsPhoneNumVerified = (dt.Rows[0]["IsPhoneNumVerified"] == DBNull.Value ? false : (bool)dt.Rows[0]["IsPhoneNumVerified"]); user.CreatedDate = (dt.Rows[0]["CreatedDate"] == DBNull.Value ? "" : dt.Rows[0]["CreatedDate"].ToString()); user.Role = (dt.Rows[0]["Role"] == DBNull.Value ? "" : dt.Rows[0]["Role"].ToString()); //user.ModifiedDate = (dt.Rows[0]["ModifiedDate"] == DBNull.Value ? "" : dt.Rows[0]["ModifiedDate"].ToString()); //user.IsDeleted = (dt.Rows[0]["IsDeleted"] == DBNull.Value ? false : (bool)dt.Rows[0]["IsDeleted"]); userList.Add(user); var token = GenerateJSONWebToken(); var encrypt = Common.EncryptData(token); return(StatusCode((int)HttpStatusCode.OK, new { user, token })); } else { //string SaveErrorLog = Data.Common.SaveErrorLog("ExternalLogin", row); return(StatusCode((int)HttpStatusCode.Forbidden, new { error = new { message = "Invalid User" } })); } } else { string SaveErrorLog = Data.Common.SaveErrorLog("ExternalLogin", "User not exist"); return(StatusCode((int)HttpStatusCode.Forbidden, new { error = new { message = "User not exist" } })); } } catch (Exception e) { string SaveErrorLog = Data.Common.SaveErrorLog("ExternalLogin", e.Message); return(StatusCode((int)HttpStatusCode.InternalServerError, new { error = new { message = e.Message.ToString() } })); } }
public ActionResult Login(UsersLogin model) { if (ModelState.IsValid && _repo.Authentication(model.Login, model.Password)) { FormsAuthentication.RedirectFromLoginPage(model.Login, false); } else { ModelState.AddModelError("", "Incorrect login or password!"); } return(View()); }
public async Task <IActionResult> Login(UsersLogin G_users) { var P_obj = _context.Users.Where(a => a.UserName == G_users.UserName && a.UserPassword == G_users.UserPassword).FirstOrDefault(); if (P_obj != null) { if (P_obj.UserAuthorization) { return(RedirectToAction("Index", "AdminPanel" /*, new { @id = P_obj.UserId }*/)); } return(RedirectToAction("Index", "UserPanel", new { @id = P_obj.UserId })); } else { ModelState.AddModelError("", "Kullanıcı adı veya şifreyi yanlış girdiniz."); } return(View(G_users)); }
public async Task <IActionResult> Register(RegisterViewModel registerViewModel) { if (ModelState.IsValid) { var user = new UsersLogin() { UserName = registerViewModel.UserName, Email = registerViewModel.Email1, LastName = registerViewModel.LastName, FirstName = registerViewModel.FirstName, PasswordHash = registerViewModel.Password }; var result = await userManager.CreateAsync(user, registerViewModel.Password); if (result.Succeeded) { return(RedirectToAction("Index", "Home")); } } return(View(registerViewModel)); }
public IActionResult UpdatePassword([FromBody] Login userlogin) { //string connectionString = configuration.GetSection("ConnectionString").GetSection("DefaultConnection").Value; UsersLogin user = new UsersLogin(); try { if (userlogin.Password == "" || userlogin.Password == null) { return(StatusCode((int)HttpStatusCode.BadRequest, new { error = new { message = "Please enter Password" } })); } else if (userlogin.Email == "" || userlogin.Email == null) { return(StatusCode((int)HttpStatusCode.BadRequest, new { error = new { message = "Please enter Email" } })); } Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"); Match match = regex.Match(userlogin.Email); if (match.Success) { string row = Data.Users.UpdatePassword(userlogin); if (row == "Success") { return(StatusCode((int)HttpStatusCode.OK, "Updated Successfully")); } else { //return "Invalid user"; return(StatusCode((int)HttpStatusCode.Forbidden, new { error = new { message = "Account not exist" } })); } } else { return(StatusCode((int)HttpStatusCode.BadRequest, new { error = new { message = "Please enter a valid Email" } })); } } catch (Exception e) { string SaveErrorLog = Data.Common.SaveErrorLog("UpdatePassword", e.Message); return(StatusCode((int)HttpStatusCode.InternalServerError, new { error = new { message = e.Message } })); } }
public LoginResponseResult Login(UsersLogin userLogin) { LoginResponseResult result = new LoginResponseResult(); string sql = String.Format(@"SELECT [UserID],[UserName],[OldPassword] as [Password],UserType,GeoType,[FullName],[Designation],[Organization] ,StaffID,[PhoneNumber] ,[Email] , convert(nvarchar(12), cast([CreateDate] as date),103) CreateDate, ISNULL( convert (nvarchar(10), cast(EditDate as date),103),'')EditDate FROM [AspNetUsers] where IsActive=1 AND UserName='******' AND OldPassword ='******' ", userLogin.UserName, userLogin.Password); result.UserInfo = _unitOfWork.context.Database.SqlQuery <LoginUserInfo>(sql).FirstOrDefault(); if (result.UserInfo != null) { if (userLogin.DeviceUniqueId != null) { var exist = _unitOfWork.GenericRepositories <DeviceInfo>().FindBy(x => x.DeviceUniqueId == userLogin.DeviceUniqueId && x.UserId == result.UserInfo.UserID).FirstOrDefault(); if (exist == null) { DeviceInfo deviceInfo = new DeviceInfo() { DeviceUniqueId = userLogin.DeviceUniqueId, UserId = result.UserInfo.UserID }; _unitOfWork.GenericRepositories <DeviceInfo>().Insert(deviceInfo); _unitOfWork.SaveChange(); sql = $@"SELECT RecordId,DeviceUniqueId,REPLACE(STR(RecordId, 5), SPACE(1), '0') DeviceId,UserId FROM DeviceInfo WHERE DeviceUniqueId='{userLogin.DeviceUniqueId}' AND UserId='{result.UserInfo.UserID}'"; var device = _unitOfWork.GenericRepositories <DeviceInfo>().GetRecordSet(sql).FirstOrDefault(); _unitOfWork.GenericRepositories <DeviceInfo>().Update(device); _unitOfWork.SaveChange(); result.UserInfo.DeviceId = device.DeviceId; } else { result.UserInfo.DeviceId = exist.DeviceId; } } } else { return(result = null); } return(result); }
public ActionResult Login(UsersLogin form) { UserDb db = new UserDb(); User user = db.GetUserByUsername(form.Username); if (!form.Username.IsEmpty()) { if (user != null) { if (BCrypt.Net.BCrypt.Verify(form.Password, db.GetUserByUsername(form.Username).Password)) { Session["username"] = user.Username; return(RedirectToRoute("Home")); } } } return(View(new UsersLogin { ErrorMessage = "Username or password is wrong!" })); }
public static string SaveUser(UsersLogin userlogin, string Action) { //int UserId, string Name, string PhoneNumber, string Email, string Password, string SourceofReg, bool IsEmailVerified, bool IsPhoneNumVerified, //bool IsPromoCodeApplicable, string Action, try { string ConnectionString = Common.GetConnectionString(); var encryptPassword = Common.EncryptData(userlogin.Password); List <SqlParameter> parameters = new List <SqlParameter>(); parameters.Add(new SqlParameter("@UserId", userlogin.UserId)); parameters.Add(new SqlParameter("@Name", userlogin.Name)); parameters.Add(new SqlParameter("@PhoneNumber", userlogin.PhoneNumber)); parameters.Add(new SqlParameter("@Email", userlogin.Email)); parameters.Add(new SqlParameter("@Password", encryptPassword)); parameters.Add(new SqlParameter("@SourceofReg", userlogin.SourceofReg)); parameters.Add(new SqlParameter("@IsEmailVerified", userlogin.IsEmailVerified)); parameters.Add(new SqlParameter("@IsPhoneNumVerified", userlogin.IsPhoneNumVerified)); parameters.Add(new SqlParameter("@IsPromoCodeApplicable", userlogin.IsPromoCodeApplicable)); parameters.Add(new SqlParameter("@Role", userlogin.Role)); parameters.Add(new SqlParameter("@Action", Action)); string rowsAffected = SqlHelper.ExecuteScalar(ConnectionString, CommandType.StoredProcedure, "spSaveUser", parameters.ToArray()).ToString(); //SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, "spSaveUser", parameters.ToArray()); return(rowsAffected); //using (DataTable dt = SqlHelper.ExecuteDataset(ConnectionString, CommandType.StoredProcedure, "spSaveUser", parameters.ToArray()).Tables[0]) //{ // int rowsAffected = SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, "spUpdatePhoneEmailStatus", parameters.ToArray()); // return rowsAffected; //} } catch (Exception e) { //loggerErr.Error(e.Message + " - " + e.StackTrace); throw e; } }
public void InsetTeachers(Teacher teacher, UsersLogin usersLogin) { try{ OpenConnection(); cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.CommandText = "InsertTeacher"; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@TeacherLastName", teacher.TeacherLastName); cmd.Parameters.AddWithValue("@TeacherFirstName", teacher.TeacherFirstName); cmd.Parameters.AddWithValue("@TeacherDepartment", teacher.TeacherDepartment); cmd.Parameters.AddWithValue("@UserEmail", usersLogin.UserEmail); cmd.Parameters.AddWithValue("@UserPassword", usersLogin.UserPassword); cmd.ExecuteNonQuery(); } catch (Exception) { throw; } finally { ClosedConnection(); } }
public JsonResult Login(Member member) { if (ModelState.IsValid) { member.username = member.username.Trim(); member.password = member.password.Trim(); var user = (from u in db.Users join ul in db.UsersLogins on u.UserID equals ul.UserID where ((u.Email.Equals(member.username)) || (u.Mobile == member.username)) && ul.Password.Equals(member.password, StringComparison.CurrentCulture) select new SessionEntity { FirstName = u.FirstName, LastName = u.LastName, LastLoginDateTime = ul.LastLoginDateTime, UserID = u.UserID, Email = u.Email }).FirstOrDefault(); if (user != null) { Session["User"] = user; UsersLogin userlogin = db.UsersLogins.Where(x => x.UserID == user.UserID).FirstOrDefault(); userlogin.LastLoginDateTime = DateTime.Now; userlogin.UpdatedDate = DateTime.Now; userlogin.UpdatedBy = user.UserID; userlogin.CreatedDate = DateTime.Now; userlogin.CreatedBy = user.UserID; db.Entry(userlogin).State = EntityState.Modified; db.SaveChanges(); return(Json(new { StatusCode = HttpStatusCode.Created }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { StatusCode = HttpStatusCode.MethodNotAllowed, StatusMessage = "Please enter required fields" }, JsonRequestBehavior.AllowGet)); } return(Json(new { StatusCode = HttpStatusCode.NotFound, StatusMessage = "User not found,Please register!!" }, JsonRequestBehavior.AllowGet)); }
private async void buttonUsersChange_Click(object sender, EventArgs e) { if (dataGridViewUsers.SelectedRows.Count > 0) { int index = dataGridViewUsers.SelectedRows[0].Index; int id = 0; bool converted = Int32.TryParse(dataGridViewUsers[0, index].Value.ToString(), out id); if (converted == false) { return; } UsersLogin prod = db.UsersLogins.Find(id); UserForm pFormChange = new UserForm(); pFormChange.LoginTextBox.Text = prod.Login; pFormChange.PasswordTextBox.Text = prod.Password; pFormChange.EmailTextBox.Text = prod.Mail; pFormChange.AdminCheck.Checked = prod.Admin; DialogResult result = pFormChange.ShowDialog(this); if (result == DialogResult.Cancel) { return; } prod.Login = pFormChange.LoginTextBox.Text; prod.Password = pFormChange.PasswordTextBox.Text; prod.Mail = pFormChange.EmailTextBox.Text; prod.Admin = pFormChange.AdminCheck.Checked; await db.SaveChangesAsync(); dataGridViewUsers.Refresh(); MessageBox.Show("object updated"); } }
public ActionResult SignUp(VMUser viewmodel) { if (ModelState.IsValid && viewmodel.VerificationCode == null) { int totalExistRows = db.Users.Where(x => x.Email.ToUpper().Equals(viewmodel.Email.ToUpper())).Count(); if (totalExistRows > 0) { viewmodel.StatusCode = 3; viewmodel.StatusMessage = "User already present"; return(View(viewmodel)); } if (!((Regex.Matches(viewmodel.Password, @"[a-zA-Z]").Count > 0) && (Regex.Matches(viewmodel.Password, @"[0-9]").Count > 0))) { viewmodel.StatusCode = 7; viewmodel.StatusMessage = "Password should contain atleast 1 Alphabet and Number"; return(View(viewmodel)); } if (viewmodel.VerificationCode == null) { string sendSms = SendSMS(viewmodel); JObject results = JObject.Parse(sendSms); if (results["errors"] != null) { foreach (var result in results["errors"]) { viewmodel.StatusCode = 1; viewmodel.StatusMessage = (string)result["message"]; } } else if (results["status"].ToString() == "success") { viewmodel.StatusCode = 2; viewmodel.StatusMessage = "Verification code sent. Please verify."; } } } else if (viewmodel.VerificationCode == null) { return(View(viewmodel)); } if (viewmodel.StatusCode == 1) { return(View(viewmodel)); } if (viewmodel.VerificationCodeTemp != null) { using (DbContextTransaction dbTran = db.Database.BeginTransaction()) { try { User user = new User() { FirstName = viewmodel.FirstName, LastName = viewmodel.LastName, Email = viewmodel.Email, Mobile = viewmodel.Mobile, UserTypeId = Convert.ToInt32(Enumerate.UserTypeId.Admin), MemberId = (Int32.Parse((from c in db.Users select c.MemberId).Max()) + 1).ToString() }; db.Users.Add(user); db.SaveChanges(); UsersLogin userlogin = new UsersLogin() { UserID = user.UserID, Password = viewmodel.Password, CreatedBy = user.UserID, CreatedDate = DateTime.Now }; db.UsersLogins.Add(userlogin); db.SaveChanges(); Verification ver = new Verification() { UserId = user.UserID, VerificationCode = viewmodel.VerificationCodeTemp, IsMobileVerified = false, IsEmailVerified = false }; db.Verifications.Add(ver); db.SaveChanges(); dbTran.Commit(); TempData["UserId"] = user.UserID; viewmodel.VerificationCodeTemp = null; viewmodel.resubmit = true; } catch (Exception e) { viewmodel.StatusCode = 4; viewmodel.StatusMessage = e.Message; dbTran.Rollback(); } } } //return RedirectToAction("Index", "Home"); if (viewmodel.VerificationCode != null) { try { Verification ver = new Verification(); int userid = (int)TempData["UserId"]; var objectVerification = (from u in db.Verifications where u.UserId == userid select new { u.UserId, u.VerificationCode, u.IsEmailVerified, u.IsMobileVerified, u.MobileVerifyDate, u.EmailVerifyDate, u.VerificationId }).FirstOrDefault(); if (objectVerification != null) { ver.VerificationId = objectVerification.VerificationId; ver.UserId = objectVerification.UserId; ver.VerificationCode = objectVerification.VerificationCode; ver.IsEmailVerified = objectVerification.IsEmailVerified; ver.IsMobileVerified = objectVerification.IsMobileVerified; ver.MobileVerifyDate = objectVerification.MobileVerifyDate; ver.EmailVerifyDate = objectVerification.EmailVerifyDate; } if (ver != null) { if (ver.VerificationCode == viewmodel.VerificationCode) { ver.IsMobileVerified = true; ver.MobileVerifyDate = DateTime.Now; db.Entry(ver).State = EntityState.Modified; db.SaveChanges(); viewmodel.StatusCode = 6; viewmodel.StatusMessage = "Mobile verified!!!"; return(RedirectToAction("Index", "Login")); } else { viewmodel.StatusCode = 5; viewmodel.StatusMessage = "Wrong Verification code entered."; } } } catch (Exception er) { viewmodel.StatusCode = 4; viewmodel.StatusMessage = er.Message; } } return(View(viewmodel)); }
public ApiResponse <Object> GetPacketByUserId(ApiPacketRequest apr) { ApiResponse <Object> returnObject = new ApiResponse <Object>(); List <object> obj = new List <object>(); switch (apr.TableName) { case "Login": { UsersLogin query = JsonConvert.DeserializeObject <UsersLogin>(apr.ApiPacket.Packet.ToString()); var result = new AspNetUsers().Login(query); ApiPacket <LoginResponse> fp = new ApiPacket <LoginResponse>() { Packet = new LoginResponse() }; if (result != null) { returnObject.ApiPacket.Packet = new LoginResponse() { UserInfo = result.UserInfo /*, BlockInfo = result.BlockInfo ServicePoint = result.ServicePoint, GeoLocation = result.GeoLocation*/ }; } ApiResponse <LoginResponse> response = new ApiResponse <LoginResponse>() { Success = result != null ? true : false, ApiPacket = fp, PageNo = apr.PageNo, PageSize = apr.PageSize, TotalRecord = 0, Message = result != null ? "Login successfully." : "Invalid Username or Password", Status = result != null ? 200 : 400 }; Tools.CopyClass(returnObject, response); break; //return returnObject; } case "UserGeo": { var result = new PermittedGeoLocation().GetPermittedGeoLocation(new PermittedGeoLocationRM { UserId = apr.UserId });; ApiPacket <PermittedGeoLocationViewModels> fp = new ApiPacket <PermittedGeoLocationViewModels>() { Packet = new PermittedGeoLocationViewModels() }; if (result != null) { returnObject.ApiPacket.Packet = new PermittedGeoLocationViewModels() { District = result.District, Upazila = result.Upazila, Unions = result.Unions, Village = result.Village, CenterInfo = result.CenterInfo, CampInfo = result.CampInfo }; } ApiResponse <PermittedGeoLocationViewModels> response = new ApiResponse <PermittedGeoLocationViewModels>() { Success = result != null ? true : false, ApiPacket = fp, PageNo = apr.PageNo, PageSize = apr.PageSize, TotalRecord = 0, Message = result != null ? "Record Fetched successfully." : "Record Fetched fail.", Status = result != null ? 200 : 400 }; Tools.CopyClass(returnObject, response); break; } case "UniqueId": { var requestObject = JsonConvert.DeserializeObject <RequestForUniqueId>(apr.ApiPacket.Packet.ToString()); var result = new UniqueId().SaveAndGet(requestObject ?? new RequestForUniqueId(), apr.UserId); returnObject = GetApiResponse(apr, result.ToList <object>(), result.Count); break; } case "SpinnerData": { var spinnerRequest = JsonConvert.DeserializeObject <SpinnerRequest>(apr.ApiPacket.Packet.ToString()); SpinnerData spinner = new SpinnerData(); var result = spinner.APIGetSpinnerData(QueryFromAPIPacketRequest(apr), spinnerRequest); obj.AddRange(result); returnObject = GetApiResponse(apr, obj, apr.TotalRecord != 0 ? spinner.APIGetTotalRecord(QueryFromAPIPacketRequest(apr), spinnerRequest) : apr.TotalRecord); break; } case "BlockInfo": { var requestObject = new ForApiResponse() { UserId = apr.UserId }; BlockInfo blockinfo = new BlockInfo(); var result = blockinfo.APIGetBlockList(requestObject); obj.AddRange(result); returnObject = GetApiResponse(apr, result.ToList <object>(), result.Count); break; } default: { ApiResponse <object> response = new ApiResponse <object>() { Success = false, ApiPacket = null, PageNo = apr.PageNo, PageSize = apr.PageSize, TotalRecord = 0, Message = "Table is not registered to System", Status = 400 }; return(response); } } return(returnObject); }
private async void buttonMenegerAdd_Click(object sender, EventArgs e) { MenegerInfoForm pFormAdd = new MenegerInfoForm(); DialogResult result; while (true) { result = pFormAdd.ShowDialog(this); if (result == DialogResult.Cancel) { return; } if (CheckUser(pFormAdd.textBoxFullName.Text, pFormAdd.textBoxAddres.Text, pFormAdd.textBoxPhone.Text)) { MenedjerInformation prod = new MenedjerInformation(); prod.Status = pFormAdd.textBoxStatus.Text; prod.Address = pFormAdd.textBoxAddres.Text; prod.FullName = pFormAdd.textBoxFullName.Text; prod.PhoneNumber = pFormAdd.textBoxPhone.Text; prod.UserLoginId = Convert.ToInt32(pFormAdd.numericUpDownUserID.Value); prod.DataOfBirth = pFormAdd.dateTimeCreated.Value.Day + "," + pFormAdd.dateTimeCreated.Value.Month + "," + pFormAdd.dateTimeCreated.Value.Year; UsersLogin uL = db.UsersLogins.FirstOrDefault(u => u.Id == prod.UserLoginId); if (uL == null) { MessageBox.Show("To add manager information you need to create an account"); UserForm uFAdd = new UserForm(); DialogResult ress; while (true) { ress = uFAdd.ShowDialog(this); if (ress == DialogResult.Cancel) { return; } if (CheckUser(uFAdd.EmailTextBox.Text)) { UsersLogin user = new UsersLogin(); user.Login = uFAdd.LoginTextBox.Text; user.Password = uFAdd.PasswordTextBox.Text; user.Mail = uFAdd.EmailTextBox.Text; user.Admin = true; db.UsersLogins.Add(user); prod.UserLogin = user; db.MenedjersInformations.Add(prod); await db.SaveChangesAsync(); MessageBox.Show("New manager and information about him"); return; } } } else { db.MenedjersInformations.Add(prod); await db.SaveChangesAsync(); MessageBox.Show("New Object Added"); return; } } } }
private async void buttonUsersAdd_Click(object sender, EventArgs e) { UserForm uFAdd = new UserForm(); DialogResult ress; while (true) { ress = uFAdd.ShowDialog(this); if (ress == DialogResult.Cancel) { return; } if (CheckUser(uFAdd.EmailTextBox.Text)) { UsersLogin user = new UsersLogin(); user.Login = uFAdd.LoginTextBox.Text; user.Password = uFAdd.PasswordTextBox.Text; user.Mail = uFAdd.EmailTextBox.Text; user.Admin = uFAdd.AdminCheck.Checked; db.UsersLogins.Add(user); await db.SaveChangesAsync(); MessageBox.Show("New Object Added"); if (user.Admin == true) { MenegerInfoForm pFormAdd = new MenegerInfoForm(); DialogResult result; while (true) { result = pFormAdd.ShowDialog(this); if (result == DialogResult.Cancel) { return; } if (CheckUser(pFormAdd.textBoxFullName.Text, pFormAdd.textBoxAddres.Text, pFormAdd.textBoxPhone.Text)) { MenedjerInformation prod = new MenedjerInformation(); prod.Status = pFormAdd.textBoxStatus.Text; prod.Address = pFormAdd.textBoxAddres.Text; prod.FullName = pFormAdd.textBoxFullName.Text; prod.PhoneNumber = pFormAdd.textBoxPhone.Text; UsersLogin us = db.UsersLogins.FirstOrDefault(u => (u.Login == user.Login || u.Mail == user.Mail) && u.Password == user.Password); if (us != null) { prod.UserLoginId = us.Id; } prod.DataOfBirth = pFormAdd.dateTimeCreated.Value.Day + "," + pFormAdd.dateTimeCreated.Value.Month + "," + pFormAdd.dateTimeCreated.Value.Year; db.MenedjersInformations.Add(prod); await db.SaveChangesAsync(); MessageBox.Show("New Object Added"); return; } } } else if (user.Admin == false) { CustumerInfoForm pFormAdd = new CustumerInfoForm(); DialogResult result; while (true) { result = pFormAdd.ShowDialog(this); if (result == DialogResult.Cancel) { return; } if (CheckUser(pFormAdd.textBoxFullName.Text, pFormAdd.textBoxAddres.Text, pFormAdd.textBoxPhone.Text)) { CustomerInformation prod = new CustomerInformation(); prod.Address = pFormAdd.textBoxAddres.Text; prod.ContactFio = pFormAdd.textBoxFullName.Text; prod.Phone = pFormAdd.textBoxPhone.Text; prod.UserLoginId = Convert.ToInt32(pFormAdd.numericUpDownUserID.Value); prod.DataOfBirth = pFormAdd.dataTimeBirth.Value.Day + "," + pFormAdd.dataTimeBirth.Value.Month + "," + pFormAdd.dataTimeBirth.Value.Year; UsersLogin us = db.UsersLogins.FirstOrDefault(u => (u.Login == user.Login || u.Mail == user.Mail) && u.Password == user.Password); if (us != null) { prod.UserLoginId = us.Id; } db.CustomersInformations.Add(prod); await db.SaveChangesAsync(); MessageBox.Show("New Object Added"); return; } } } } } }
public IActionResult SaveUser([FromBody] UsersLogin userlogin) //int UserId, string Name, string PhoneNumber, string Email, string Password, string SourceofReg, bool IsEmailVerified, bool IsPhoneNumVerified, //bool IsPromoCodeApplicable, string Action { //string GetConnectionString = UsersController.GetConnectionString(); List <UsersLogin> userList = new List <UsersLogin>(); string Action = "Add"; if (userlogin.Role != "Admin") { userlogin.Role = "User"; } try { if (userlogin.Name == "" || userlogin.Name == "string" || userlogin.Name == null) { return(StatusCode((int)HttpStatusCode.BadRequest, new { error = new { message = "Please enter Name" } })); } else if (userlogin.Password == "" || userlogin.Password == "string" || userlogin.Password == null) { return(StatusCode((int)HttpStatusCode.BadRequest, new { error = new { message = "Please enter Password" } })); } else if (userlogin.Email == "" || userlogin.Email == "string" || userlogin.Email == null) { return(StatusCode((int)HttpStatusCode.BadRequest, new { error = new { message = "Please enter Email" } })); } Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"); Match match = regex.Match(userlogin.Email); if (match.Success) { string row = Data.Users.SaveUser(userlogin, Action); string res = ""; string smsres = ""; if (row == "Success") { var FilePath = _env.WebRootPath + Path.DirectorySeparatorChar.ToString() + "EmailView" + Path.DirectorySeparatorChar.ToString() + "EmailTemplate.html"; var ImagePath = _env.WebRootPath + Path.DirectorySeparatorChar.ToString() + "Images" + Path.DirectorySeparatorChar.ToString() + "PopTheHood_Logo.jpg"; string OTPValue = Common.GenerateOTP(); //res = EmailSendGrid.Mail("*****@*****.**", "*****@*****.**", "User Registration", userlogin.Name, "Hi " + userlogin.Name + " , your OTP is " + OTPValue + " and it's expiry time is 5 minutes.", FilePath).Result; // "*****@*****.**", var results = ""; //results = SmsNotification.SendMessage("7010214439", "Hi User, your OTP is" + OTPValue + "and it's expiry time is 5 minutes.").ToString(); // results = SmsNotification.SendMessage(userlogin.PhoneNumber, "Hi User, your OTP is" + OTPValue + "and it's expiry time is 5 minutes.").Status.ToString(); //var client = new Client(creds: new Nexmo.Api.Request.Credentials //{ // ApiKey = "5d5eb59f", // ApiSecret = "xFT1BuHaxN6wzA8M" //}); //var results = client.SMS.Send(new SMS.SMSRequest //{ // from = "7708178085", // to = "7010214439", // text = "Hi User, your OTP is" + OTPValue //}); var SmsStatus = ""; if (results == "RanToCompletion") { string SaveOtpValue = Data.Common.SaveOTP(userlogin.PhoneNumber, OTPValue, "Phone"); SmsStatus = "Message sent successfully."; } else { SmsStatus = "Message not sent.."; } var result = ""; if (res == "Accepted") { string SaveOtpValue = Data.Common.SaveOTP(userlogin.Email, OTPValue, "Email"); result = "Mail sent successfully."; } else { result = "Bad Request"; } //return StatusCode((int)HttpStatusCode.OK, new { Data = "Saved Successfully", Mailing = result, SMS = results, SMSSTATUS = SmsStatus, OTP = OTPValue, Status = "Success" }); return(StatusCode((int)HttpStatusCode.OK, "Saved Successfully")); } else { //return "Invalid user"; //var expected = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(new { foo = "abcd" })); return(StatusCode((int)HttpStatusCode.Forbidden, new { error = new { message = "invalid user" } })); } } else { return(StatusCode((int)HttpStatusCode.BadRequest, new { error = new { message = "Please enter a valid Email" } })); } } catch (Exception e) { string SaveErrorLog = Data.Common.SaveErrorLog("SaveUser", e.Message.ToString()); return(StatusCode((int)HttpStatusCode.InternalServerError, new { error = new { message = e.Message.ToString() } })); } }
public static async void FillDataBase() { List <string> ReferenceByTelemart = new List <string>() { "https://telemart.ua/ua/processor/", "https://telemart.ua/ua/motherboard/", "https://telemart.ua/ua/videocard/", "https://telemart.ua/ua/ram/", "https://telemart.ua/ua/hard-drive/", "https://telemart.ua/ua/case/", "https://telemart.ua/ua/powersuply/", "https://telemart.ua/ua/ua/mouse/", "https://telemart.ua/ua/keyboards/", "https://telemart.ua/ua/kovriki/", "https://telemart.ua/ua/microphones/", "https://telemart.ua/ua/earphones/", "https://telemart.ua/ua/web-cam/", "https://telemart.ua/ua/hdmi-dvi-vga-cables/", "https://telemart.ua/ua/monitors/filter/for-office-tasks/", "https://telemart.ua/ua/monitors/filter/for-game/", "https://telemart.ua/ua/monitors/filter/work-with-graphics/", "https://telemart.ua/ua/monitors/", "https://telemart.ua/ua/laptops/filter/1920x1080/", "https://telemart.ua/ua/laptops/filter/geforce-1080/geforce-1660-ti/geforce-2060/geforce-2070/geforce-2080/", "https://telemart.ua/ua/laptops/", "https://telemart.ua/ua/pc/filter/t-gaming/", "https://telemart.ua/ua/pc/filter/t-ultra/", }; List <string> CategoriesNameForReferance = new List <string>() { "Processor", "Motherboard", "Videocard", "Ram", "HardDrive", "Case", "Powersuply", "Mouse", "Keyboard", "Capet", "Microphone", "Headset", "Camera", "Cabel", "MonitorOfice", "MonitorGame", "MonitorDisign", "MonitorAll", "NoutbookOfice", "NoutbookGame", "NoutbookAll", "PcGame", "PcUltra" }; using (DataBaseIM db = new DataBaseIM()) { UsersLogin uL = new UsersLogin(); uL.Admin = true; uL.Login = "******"; uL.Password = "******"; uL.Mail = "*****@*****.**"; MenedjerInformation mInfo = new MenedjerInformation(); mInfo.UserLogin = uL; db.UsersLogins.Add(uL); db.MenedjersInformations.Add(mInfo); Console.WriteLine("Менеджер Admin доданий в базу даних\n"); for (int l = 0; l < ReferenceByTelemart.Count; l++) { List <Product> productList = new List <Product>(); var parser = new Parser(); var result = parser.GetInfo(ReferenceByTelemart[l]).Result; try { for (int i = 0; i < result.Title.Count; i++) { Product p = new Product(); //Categoty p.ProductCategory = CategoriesNameForReferance[l]; p.Title = result.Title[i]; Regex regex = new Regex(@"\s*грн"); string clear = regex.Replace(result.Price[i], ""); regex = new Regex(@"\s+"); clear = regex.Replace(clear, ""); p.Price = clear; //Reference on image p.ImageData = result.Images[i]; //Characteristics string[] s = Regex.Split(result.Characteristics[i], "</div>"); s = Regex.Split(s[1], "<br>"); List <Characteristic> listCharact = new List <Characteristic>(); foreach (var iteDataBaseIM in s) { Characteristic ch = new Characteristic(); string target = ""; regex = new Regex(@"<[^>]*>"); string withoutTags = regex.Replace(iteDataBaseIM, target); regex = new Regex(@"^\s+"); clear = regex.Replace(withoutTags, target); ch.CharacteristicString = clear; listCharact.Add(ch); } p.Characteristics = listCharact; productList.Add(p); } db.Products.AddRange(productList); await db.SaveChangesAsync(); Console.WriteLine("Link : " + l + " uploaded"); } catch (Exception) { Console.WriteLine("Eror by: " + l); } } Console.WriteLine("All links uploaded successfully"); } }
public IActionResult UpdateUser([FromBody] UsersLogin userlogin) { List <UsersLogin> userList = new List <UsersLogin>(); string Action = "Update"; try { if (userlogin.Name == "" || userlogin.Name == "string") { return(StatusCode((int)HttpStatusCode.BadRequest, new { error = new { message = "Please enter Name" } })); } else if (userlogin.UserId <= 0 || userlogin.UserId == null) { return(StatusCode((int)HttpStatusCode.BadRequest, new { error = new { message = "Please enter UserID" } })); } else if (userlogin.Email == "" || userlogin.Email == "string") { return(StatusCode((int)HttpStatusCode.BadRequest, new { error = new { message = "Please enter Email" } })); } Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"); Match match = regex.Match(userlogin.Email); if (match.Success) { string row = Data.Users.SaveUser(userlogin, Action); if (row == "Success") { //string OTPValue = Common.GenerateOTP(); //var results = ""; //var SmsStatus = ""; //if (results == "RanToCompletion") //{ // string SaveOtpValue = Data.Common.SaveOTP("4560123045", OTPValue, "Phone"); // SmsStatus = "Message sent successfully."; //} //else //{ // SmsStatus = "Message not sent.."; //} //var result = ""; //if (res == "Accepted") //{ // string SaveOtpValue = Data.Common.SaveOTP("*****@*****.**", OTPValue, "Email"); // result = "Mail sent successfully."; //} //else //{ // result = "Bad Request"; //} return(StatusCode((int)HttpStatusCode.OK, "Updated Successfully")); } else { //return "Invalid user"; return(StatusCode((int)HttpStatusCode.Forbidden, new { error = new { message = "Invalid User" } })); } } else { return(StatusCode((int)HttpStatusCode.BadRequest, new { error = new { message = "Please enter a valid Email" } })); } } catch (Exception e) { string SaveErrorLog = Data.Common.SaveErrorLog("UpdateUser", e.Message.ToString()); return(StatusCode((int)HttpStatusCode.InternalServerError, new { error = new { message = e.Message.ToString() } })); } }