public ActionResult Edit(int? id) { var user = DisplayCurUser(); if (!user.HasAccess(AdGroup.PersonalManager)) return RedirectToAction("AccessDenied", "Error"); if (id.HasValue) { var dep = new Budget(id.Value); return View(dep); } else { return View("New"); } }
public ActionResult Edit(Budget model) { if (!CurUser.HasAccess(AdGroup.PersonalManager)) return RedirectToAction("AccessDenied", "Error"); try { ResponseMessage responseMessage; bool complete = model.Save(out responseMessage); if (!complete) throw new Exception(responseMessage.ErrorMessage); return RedirectToAction("Index", new { id = responseMessage.Id }); } catch (Exception ex) { ViewData["ServerError"] = ex.Message; return RedirectToAction("Edit", new { id = model.Id }); } }
public ActionResult Index(Budget model) { if (!CurUser.HasAccess(AdGroup.PersonalManager)) return RedirectToAction("AccessDenied", "Error"); try { ResponseMessage responseMessage; bool complete = model.Save(out responseMessage); if (!complete) throw new Exception(responseMessage.ErrorMessage); TempData["ServerSuccess"] = "Бюджет успешно добавлен"; return RedirectToAction("Index"); } catch (Exception ex) { TempData["ServerError"] = ex.Message; return View("Index", model); } }
private void FillSelf(Budget model) { Id = model.Id; Name = model.Name; Descr = model.Descr; IdParent = model.IdParent; }