public List <InspectorListModel> GetInspectorList(int ARCSOfficerCode) { connection.Open(); List <InspectorListModel> lstILM = new List <InspectorListModel>(); SqlCommand cmd = new SqlCommand("[dbo].[GetInsepectorList]", connection) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@ARCSCode", ARCSOfficerCode); var dr = cmd.ExecuteReader(); var dt = new DataTable(); if (dr.HasRows) { dt.Load(dr); if (dt.Rows.Count > 0) { foreach (DataRow r in dt.Rows) { InspectorListModel objILM = new InspectorListModel { InspectorId = r["InspectorCode"].ToString(), InspectorName = r["InspectName"].ToString() }; lstILM.Add(objILM); } } } connection.Close(); return(lstILM); }
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()); }