public ActionResult Delete(int refTypeId, int id) { //Find a customer with ProductID equal to the id action parameter zz_Reference reference = refRepo.GetOne(id); this.refRepo.CurrentUserName = HttpContext.User.Identity.Name; if (reference != null) { try { //Delete the record refRepo.DoDelete(reference); new RecordDeletedEvent("Reference", reference.Id, reference.RefTypeId, reference.Code, reference.RefName, null).Raise(); } catch (ApplicationException ex) { TempData.AddError(ex.ExMessage()); } } return(RedirectToAction("Index", new { refTypeId = refTypeId })); }
public ActionResult Insert(int refTypeId, string Code) { //Create a new instance of the zz_Reference class. zz_Reference reference = new zz_Reference(); this.refRepo.CurrentUserName = HttpContext.User.Identity.Name; //Perform model binding (fill the reference properties and validate it). try { refRepo.DoNewRecord(refTypeId, Code, reference); UpdateModel(reference, string.Empty, null, new string[] { "Code" }); //ไม่ต้อง Update Field Code เพราะใน DoNewRecord ทำแล้ว และใน Save ก็มีเช็คซ้ำ //The model is valid - insert the reference. refRepo.DoSave(reference, true); //return RedirectToAction("Index", new { refTypeId = refTypeId }); } catch (RulesException ex) { ex.CopyTo(ModelState); } return(RedirectToAction("Index", new { refTypeId = refTypeId })); }
public ActionResult Update(int refTypeId, int id) { zz_Reference reference = refRepo.GetOne(id); this.refRepo.CurrentUserName = HttpContext.User.Identity.Name; try { UpdateModel(reference); refRepo.DoSave(reference, false); //RouteValueDictionary routeValues = this.GridRouteValues(); //routeValues.Add("refTypeId", refTypeId); //return RedirectToAction("Index", routeValues); //return RedirectToAction("Index", new { refTypeId = refTypeId }); } catch (RulesException ex) { ex.CopyTo(ModelState); } return(RedirectToAction("Index", new { refTypeId = refTypeId })); //return Index(refTypeId); }