public ActionResult Insert(Staying90Day stay, bool wantClose) { //Staying90Day stay = new Staying90Day(); this.stayRepo.CurrentUserName = HttpContext.User.Identity.Name; try { stayRepo.DoNewRecord(stay); UpdateModel(stay); stayRepo.DoSave(stay, true); TempData.AddInfo(Resources.Messages.SaveSuccess); if (!wantClose) { return(RedirectToAction("Edit", new { id = stay.Id })); } return(RedirectToAction("Index2")); } catch (RulesException ex) { ex.CopyTo(ModelState); TempData.AddWarning(Resources.Messages.SaveError + ex.ExMessage()); } catch (Exception ex) { TempData.AddWarning(Resources.Messages.SaveError + ex.ExMessage()); } return(doInsert(stay)); }
public ActionResult Delete(int id) { Staying90Day stay = stayRepo.GetOne(id); if (stay != null) { try { //Delete the record stayRepo.DoDelete(stay); new RecordDeletedEvent("Staying90Day", stay.Id, 0, stay.Code, stay.Alien.Name.FullName, null).Raise(); TempData.AddInfo(Resources.Messages.DeleteSuccess + " (" + stay.Code + "-" + stay.Alien.Name.FullName + ")"); } catch (Exception ex) { TempData.AddError(ex.ExMessage()); return(RedirectToAction("Edit", new { id = id })); } } else { TempData.AddError(Resources.Messages.NotFoundData); } return(RedirectToAction("Index2")); }
private ActionResult doInsert(Staying90Day stay) { ToolbarMenuHelpers.SetToolBar(ViewData, new { Save = "btnSave", New = "Insert", Close = "Index2" }, "Stay"); //makeReferenceViewData(); stay.Code = stayRepo.GetNewCode(); return(View(stay)); }
private ActionResult doEdit(Staying90Day stay) { ToolbarMenuHelpers.SetToolBar(ViewData, new { Save = "btnSave", New = "Insert", GiveUp = "btnDelete", Close = "Index2" }, "Stay"); //ส่งผ่านตัวแปรเพื่อทำ combobox //makeReferenceViewData(); if (stay != null) { return(View(stay)); } else { TempData.AddError(Resources.Messages.NotFoundData); return(RedirectToAction("Index2")); } }