public ActionResult Authorize(string id) { if (string.IsNullOrEmpty(id)) { return(RedirectToAction("AuthList", "DQQue")); } var querecord = _dqQueService.GetQueDetailItembyId(Convert.ToInt32(id)); if (querecord == null) { return(RedirectToAction("AuthList", "DQQue")); } //get all changed columns CustomerNOKModel model = new CustomerNOKModel(); model = (from c in _db.CDMA_INDIVIDUAL_NEXT_OF_KIN where c.CUSTOMER_NO == querecord.CUST_ID where c.AUTHORISED == "U" select new CustomerNOKModel { CUSTOMER_NO = c.CUSTOMER_NO, TITLE = c.TITLE, SURNAME = c.SURNAME, FIRST_NAME = c.FIRST_NAME, OTHER_NAME = c.OTHER_NAME, DATE_OF_BIRTH = c.DATE_OF_BIRTH, SEX = c.SEX, RELATIONSHIP = c.RELATIONSHIP, EMAIL_ADDRESS = c.EMAIL_ADDRESS, NEXT_OF_KIN_RESIDENTIALSTREET = c.NEXT_OF_KIN_RESIDENTIALSTREET, NOK_ADDRESS_NO = c.NOK_ADDRESS_NO, CITY_TOWN = c.CITY_TOWN, LGA = c.LGA, NEAREST_BUS_STOP_LANDMARK = c.NEAREST_BUS_STOP_LANDMARK, STATE = c.STATE, NEXT_OF_KIN_PHONE_NUMBER = c.NEXT_OF_KIN_PHONE_NUMBER, NEXT_OF_KIN_PHONE_NUMBER2 = c.NEXT_OF_KIN_PHONE_NUMBER2, BRANCH_CODE = c.BRANCH_CODE, LastUpdatedby = c.LAST_MODIFIED_BY, LastUpdatedDate = c.LAST_MODIFIED_DATE, LastAuthdby = c.AUTHORISED_BY, LastAuthDate = c.AUTHORISED_DATE, ExceptionId = querecord.EXCEPTION_ID }).FirstOrDefault(); var changelog = _db.CDMA_CHANGE_LOGS.Where(a => a.ENTITYNAME == "CDMA_INDIVIDUAL_NEXT_OF_KIN" && a.PRIMARYKEYVALUE == querecord.CUST_ID).OrderByDescending(a => a.DATECHANGED).FirstOrDefault(); if (changelog != null && model != null) { string changeId = changelog.CHANGEID; var changedSet = _db.CDMA_CHANGE_LOGS.Where(a => a.CHANGEID == changeId); foreach (var item in model.GetType().GetProperties()) //BindingFlags.Public | BindingFlags.Static { foreach (var item2 in changedSet) { if (item2.PROPERTYNAME == item.Name) { ModelState.AddModelError(item.Name, string.Format("Field has been modified, value was {0}", item2.OLDVALUE)); } } } } model.ReadOnlyForm = "True"; PrepareModel(model); return(View(model)); }
public ActionResult Edit(string id) { if (string.IsNullOrEmpty(id)) { return(RedirectToAction("Create")); } int records = _db.CDMA_INDIVIDUAL_NEXT_OF_KIN.Count(o => o.CUSTOMER_NO == id); var model = new CustomerNOKModel(); if (records > 1) { model = (from c in _db.CDMA_INDIVIDUAL_NEXT_OF_KIN where c.CUSTOMER_NO == id where c.AUTHORISED == "U" select new CustomerNOKModel { CUSTOMER_NO = c.CUSTOMER_NO, TITLE = c.TITLE, SURNAME = c.SURNAME, FIRST_NAME = c.FIRST_NAME, OTHER_NAME = c.OTHER_NAME, DATE_OF_BIRTH = c.DATE_OF_BIRTH, SEX = c.SEX, RELATIONSHIP = c.RELATIONSHIP, EMAIL_ADDRESS = c.EMAIL_ADDRESS, NEXT_OF_KIN_RESIDENTIALSTREET = c.NEXT_OF_KIN_RESIDENTIALSTREET, NOK_ADDRESS_NO = c.NOK_ADDRESS_NO, CITY_TOWN = c.CITY_TOWN, LGA = c.LGA, NEAREST_BUS_STOP_LANDMARK = c.NEAREST_BUS_STOP_LANDMARK, STATE = c.STATE, NEXT_OF_KIN_PHONE_NUMBER = c.NEXT_OF_KIN_PHONE_NUMBER, NEXT_OF_KIN_PHONE_NUMBER2 = c.NEXT_OF_KIN_PHONE_NUMBER2, BRANCH_CODE = c.BRANCH_CODE, }).FirstOrDefault(); } else if (records == 1) { model = (from c in _db.CDMA_INDIVIDUAL_NEXT_OF_KIN where c.CUSTOMER_NO == id where c.AUTHORISED == "A" select new CustomerNOKModel { CUSTOMER_NO = c.CUSTOMER_NO, TITLE = c.TITLE, SURNAME = c.SURNAME, FIRST_NAME = c.FIRST_NAME, OTHER_NAME = c.OTHER_NAME, DATE_OF_BIRTH = c.DATE_OF_BIRTH, SEX = c.SEX, RELATIONSHIP = c.RELATIONSHIP, EMAIL_ADDRESS = c.EMAIL_ADDRESS, NEXT_OF_KIN_RESIDENTIALSTREET = c.NEXT_OF_KIN_RESIDENTIALSTREET, NOK_ADDRESS_NO = c.NOK_ADDRESS_NO, CITY_TOWN = c.CITY_TOWN, LGA = c.LGA, NEAREST_BUS_STOP_LANDMARK = c.NEAREST_BUS_STOP_LANDMARK, STATE = c.STATE, NEXT_OF_KIN_PHONE_NUMBER = c.NEXT_OF_KIN_PHONE_NUMBER, NEXT_OF_KIN_PHONE_NUMBER2 = c.NEXT_OF_KIN_PHONE_NUMBER2, BRANCH_CODE = c.BRANCH_CODE, }).FirstOrDefault(); } PrepareModel(model); var nokcustid = ""; try { nokcustid = _db.MdmDqRunExceptions.Where(a => a.CATALOG_TABLE_NAME == "CDMA_INDIVIDUAL_NEXT_OF_KIN" && a.CUST_ID == model.CUSTOMER_NO).OrderByDescending(a => a.CREATED_DATE).FirstOrDefault().CUST_ID; } catch (Exception e) { Console.WriteLine(e.Message); } if (nokcustid != "" && model != null) { var exceptionSet = _db.MdmDqRunExceptions.Where(a => a.CUST_ID == nokcustid); //.Select(a=>a.PROPERTYNAME); if (nokcustid != null) { foreach (var item in model.GetType().GetProperties()) //BindingFlags.Public | BindingFlags.Static { foreach (var item2 in exceptionSet) { if (item2.CATALOG_TAB_COL == item.Name) { ModelState.AddModelError(item.Name, string.Format("Attention!")); } } //props.Add(item.Name); } } } return(View(model)); }