public int SaveResgiratedUser(ResgirationModels objRM) { SqlParameter[] param = new SqlParameter[] { new SqlParameter("@Password", objRM.Password), new SqlParameter("@DeptID", objRM.DeptID), new SqlParameter("@DisCode", objRM.DisCode), new SqlParameter("@Username", objRM.Username), new SqlParameter("@UserTypeCode", objRM.UserTypeCode), new SqlParameter("@DeptDesignationCode", objRM.DeptDesignationCode), new SqlParameter("@FirstName", objRM.FirstName), new SqlParameter("@EmailID", objRM.EmailID), new SqlParameter("@IsChanged", objRM.IsChanged), new SqlParameter("@CreatedBy", objRM.CreatedBy), new SqlParameter("@SecurityQuestionCode", objRM.SecurityQuestionCode), new SqlParameter("@SecurityAnswer", objRM.SecurityAnswer), new SqlParameter("@Role", objRM.Role), new SqlParameter("@Address1", objRM.Address1), new SqlParameter("@Address2", objRM.Address2), new SqlParameter("@PostalCode", objRM.PostalCode), new SqlParameter("@Salt", objRM.Salt), new SqlParameter("@PostOffice", objRM.PostOffice), new SqlParameter("@Age", objRM.Age), new SqlParameter("@Gender", objRM.Gender), new SqlParameter("@Mobile", objRM.Mobile), }; var details = SqlHelper.ExecuteNonQuery(Utility.GetConString(), CommandType.StoredProcedure, "[dbo].[SaveResgiratedUser]", param); if (details >= 1) { return(1); } return(0); }
public ActionResult CreateInspectorAccount(FormCollection collection) { InspectorListModel objILM = new InspectorListModel(); ResgirationModels objRM = new ResgirationModels(); EncryptionService objES = new EncryptionService(); GetDRCSName objGDN = new GetDRCSName(); Account objAcc = new Account(); var salt = objES.CreateSalt(); objRM.Username = collection.Get("UserName"); objRM.Password = objES.EncryptPassword(collection.Get("Password"), salt); objRM.SecurityQuestionCode = collection.Get("SecurityQuestions"); objRM.SecurityAnswer = collection.Get("Anwser"); objRM.Salt = salt; objGDN.DRCSName = collection.Get("DRCSName"); objILM.InspectorName = collection.Get("InspectorOffice"); objRM.FirstName = collection.Get("Name"); if (string.IsNullOrEmpty(objRM.FirstName)) { ModelState.AddModelError("Name", "Please Enter the Name"); } objRM.Mobile = collection.Get("Mobile"); objRM.EmailID = collection.Get("Email"); objRM.Gender = collection.Get("Gender"); objRM.DisCode = collection.Get("District"); objRM.ARCSCode = collection.Get("ARCSOffice"); objRM.UserTypeCode = 4; objRM.Role = 3; objRM.CreatedBy = "Admin"; if (ModelState.IsValid) { int result = objAcc.SaveResgiratedUser(objRM); if (result == 1) { return(RedirectToAction("Dashboard", "Admin")); } } else { return(View()); } return(View()); }
//[ValidateAntiForgeryToken] public ActionResult Registration(FormCollection collection) { try { ResgirationModels objRM = new ResgirationModels(); EncryptionService objES = new EncryptionService(); Account objAcc = new Account(); var salt = objES.CreateSalt(); objRM.Username = collection.Get("UserName"); string pwd = collection.Get("Password"); objRM.Password = objES.EncryptPassword(pwd, salt); objRM.SecurityQuestionCode = collection.Get("SecurityQuestions"); objRM.SecurityAnswer = collection.Get("Anwser"); objRM.Salt = salt; objRM.FirstName = collection.Get("Name"); if (string.IsNullOrEmpty(objRM.FirstName)) { ModelState.AddModelError("Name", "Please Enter the Name"); } objRM.Gender = collection.Get("Gender"); objRM.Age = Convert.ToInt32(collection.Get("Age")); objRM.Mobile = collection.Get("Mobile"); objRM.EmailID = collection.Get("Email"); objRM.Address1 = collection.Get("Address"); objRM.Address2 = collection.Get("HouseNoSectorNoRoad"); objRM.PostOffice = collection.Get("PostOffice"); objRM.PostalCode = collection.Get("PostalCode"); objRM.DisCode = collection.Get("District"); objRM.UserTypeCode = 3; objRM.Role = 1; objRM.CreatedBy = "self"; objRM.FirstName = Microsoft.Security.Application.Sanitizer.GetSafeHtmlFragment(objRM.FirstName); objRM.EmailID = Microsoft.Security.Application.Sanitizer.GetSafeHtmlFragment(objRM.EmailID); objRM.SecurityAnswer = Microsoft.Security.Application.Sanitizer.GetSafeHtmlFragment(objRM.SecurityAnswer); objRM.Address1 = Microsoft.Security.Application.Sanitizer.GetSafeHtmlFragment(objRM.Address1); objRM.Address2 = Microsoft.Security.Application.Sanitizer.GetSafeHtmlFragment(objRM.Address2); objRM.PostOffice = Microsoft.Security.Application.Sanitizer.GetSafeHtmlFragment(objRM.PostOffice); objRM.FirstName = XCCPrevent.FilterBadchars1(objRM.FirstName); objRM.EmailID = XCCPrevent.FilterBadchars1(objRM.EmailID); objRM.SecurityAnswer = XCCPrevent.FilterBadchars1(objRM.SecurityAnswer); objRM.Address1 = XCCPrevent.FilterBadchars1(objRM.Address1); objRM.Address2 = XCCPrevent.FilterBadchars1(objRM.Address2); objRM.PostOffice = XCCPrevent.FilterBadchars1(objRM.PostOffice); if (ModelState.IsValid) { int result = objAcc.SaveResgiratedUser(objRM); if (result == 1) { TempData["message"] = "Registered"; return(RedirectToAction("Login", "Account")); } } else { return(View()); } } catch (Exception ex) { return(RedirectToAction("Error", "Unauthorised")); throw ex; } return(View()); }