コード例 #1
0
        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");
            }
        }
コード例 #2
0
        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 });
            }
        }
コード例 #3
0
ファイル: BudgetController.cs プロジェクト: WakeDown/UnitApis
        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);
            }
        }
コード例 #4
0
ファイル: Budget.cs プロジェクト: aleks19921015/Stuff
 private void FillSelf(Budget model)
 {
     Id = model.Id;
     Name = model.Name;
     Descr = model.Descr;
     IdParent = model.IdParent;
 }