public ActionResult DeleteConfirmed(string id) { CDMA_CUSTOMER_INCOME cDMA_CUSTOMER_INCOME = _db.CDMA_CUSTOMER_INCOME.Find(id); _db.CDMA_CUSTOMER_INCOME.Remove(cDMA_CUSTOMER_INCOME); _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit_1([Bind(Include = "CUSTOMER_NO,INCOME_BAND,INITIAL_DEPOSIT,CREATED_DATE,CREATED_BY,LAST_MODIFIED_DATE,LAST_MODIFIED_BY,AUTHORISED,AUTHORISED_BY,AUTHORISED_DATE,IP_ADDRESS")] CDMA_CUSTOMER_INCOME cDMA_CUSTOMER_INCOME) { if (ModelState.IsValid) { _db.Entry(cDMA_CUSTOMER_INCOME).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cDMA_CUSTOMER_INCOME)); }
// GET: CustIncome/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CDMA_CUSTOMER_INCOME cDMA_CUSTOMER_INCOME = _db.CDMA_CUSTOMER_INCOME.Find(id); if (cDMA_CUSTOMER_INCOME == null) { return(HttpNotFound()); } return(View(cDMA_CUSTOMER_INCOME)); }
public ActionResult Create(CustomerIncomeModel cimodel, bool continueEditing) { //if (!_permissionService.Authorize(StandardPermissionProvider.ManageStores)) // return AccessDeniedView(); if (!User.Identity.IsAuthenticated) { return(AccessDeniedView()); } var identity = ((CustomPrincipal)User).CustomIdentity; string ip_address = Request.ServerVariables["REMOTE_ADDR"].ToString(); if (ModelState.IsValid) { CDMA_CUSTOMER_INCOME custi = new CDMA_CUSTOMER_INCOME { CUSTOMER_NO = cimodel.CUSTOMER_NO, INCOME_BAND = cimodel.INCOME_BAND, INITIAL_DEPOSIT = cimodel.INITIAL_DEPOSIT, CREATED_BY = identity.ProfileId.ToString(), CREATED_DATE = DateTime.Now, LAST_MODIFIED_BY = identity.ProfileId.ToString(), LAST_MODIFIED_DATE = DateTime.Now, AUTHORISED_BY = null, AUTHORISED_DATE = null, IP_ADDRESS = ip_address, }; _db.CDMA_CUSTOMER_INCOME.Add(custi); _db.SaveChanges(); //_localizationService.GetResource("Admin.Configuration.Stores.Added") SuccessNotification("New CUSTI has been Added"); //do activity log return(continueEditing ? RedirectToAction("Edit", new { id = cimodel.CUSTOMER_NO }) : RedirectToAction("Create")); //return RedirectToAction("Index"); } PrepareModel(cimodel); return(View(cimodel)); }
public ActionResult Edit(CustomerIncomeModel cimodel, bool continueEditing) { if (!User.Identity.IsAuthenticated) { return(AccessDeniedView()); } var identity = ((CustomPrincipal)User).CustomIdentity; bool updateFlag = false; if (ModelState.IsValid) { CDMA_CUSTOMER_INCOME originalObject = new CDMA_CUSTOMER_INCOME(); using (var db = new AppDbContext()) { int records = db.CDMA_CUSTOMER_INCOME.Count(o => o.CUSTOMER_NO == cimodel.CUSTOMER_NO); // && o.AUTHORISED == "U" && o.LAST_MODIFIED_BY == identity.ProfileId.ToString() //if there are more than one records, the 'U' one is the edited one if (records > 1) { updateFlag = true; originalObject = _db.CDMA_CUSTOMER_INCOME.Where(o => o.CUSTOMER_NO == cimodel.CUSTOMER_NO && o.AUTHORISED == "U").FirstOrDefault(); var entity = db.CDMA_CUSTOMER_INCOME.FirstOrDefault(o => o.CUSTOMER_NO == cimodel.CUSTOMER_NO && o.AUTHORISED == "U"); if (entity != null) { entity.INCOME_BAND = cimodel.INCOME_BAND; entity.INITIAL_DEPOSIT = cimodel.INITIAL_DEPOSIT; entity.LAST_MODIFIED_BY = identity.ProfileId.ToString(); entity.LAST_MODIFIED_DATE = DateTime.Now; //entity.AUTHORISED = "U"; db.CDMA_CUSTOMER_INCOME.Attach(entity); db.Entry(entity).State = EntityState.Modified; db.SaveChanges(identity.ProfileId.ToString(), cimodel.CUSTOMER_NO, updateFlag, originalObject); _messageService.LogEmailJob(identity.ProfileId, entity.CUSTOMER_NO, MessageJobEnum.MailType.Change); } } else if (records == 1) { updateFlag = false; var entity = db.CDMA_CUSTOMER_INCOME.FirstOrDefault(o => o.CUSTOMER_NO == cimodel.CUSTOMER_NO && o.AUTHORISED == "A"); originalObject = _db.CDMA_CUSTOMER_INCOME.Where(o => o.CUSTOMER_NO == cimodel.CUSTOMER_NO && o.AUTHORISED == "A").FirstOrDefault(); if (originalObject != null) { entity.INCOME_BAND = cimodel.INCOME_BAND; entity.INITIAL_DEPOSIT = cimodel.INITIAL_DEPOSIT; entity.LAST_MODIFIED_BY = identity.ProfileId.ToString(); entity.LAST_MODIFIED_DATE = DateTime.Now; db.CDMA_CUSTOMER_INCOME.Attach(entity); db.Entry(entity).State = EntityState.Modified; db.SaveChanges(identity.ProfileId.ToString(), cimodel.CUSTOMER_NO, updateFlag, originalObject); //track the audit var newentity = new CDMA_CUSTOMER_INCOME(); newentity.INCOME_BAND = cimodel.INCOME_BAND; newentity.INITIAL_DEPOSIT = cimodel.INITIAL_DEPOSIT; newentity.AUTHORISED = "U"; newentity.CREATED_BY = identity.ProfileId.ToString(); newentity.CREATED_DATE = DateTime.Now; newentity.CUSTOMER_NO = cimodel.CUSTOMER_NO; db.CDMA_CUSTOMER_INCOME.Add(newentity); db.SaveChanges(); _messageService.LogEmailJob(identity.ProfileId, newentity.CUSTOMER_NO, MessageJobEnum.MailType.Change); } else { string errorMessage = string.Format("Cannot update record with Id:{0} as it's not available.", cimodel.CUSTOMER_NO); ModelState.AddModelError("", errorMessage); } } } SuccessNotification("CUSTI Updated"); return(continueEditing ? RedirectToAction("Edit", new { id = cimodel.CUSTOMER_NO }) : RedirectToAction("Index", "DQQue")); //return RedirectToAction("Index"); } PrepareModel(cimodel); return(View(cimodel)); }