コード例 #1
0
        public ActionResult Edit(int? id)
        {
            var user = DisplayCurUser();
            if (!user.UserCanEdit()) return RedirectToAction("AccessDenied", "Error");

            if (id.HasValue)
            {
                var dep = new Department(id.Value);
                return View(dep);
            }
            else
            {
                return View("New");
            }
        }
コード例 #2
0
        public ActionResult Edit(Department dep)
        {
            var user = DisplayCurUser();
            if (!user.UserCanEdit()) return RedirectToAction("AccessDenied", "Error");

            try
            {
                ResponseMessage responseMessage;
                bool complete = dep.Save(out responseMessage);
                if (!complete) throw new Exception(responseMessage.ErrorMessage);

                return RedirectToAction("Edit", "Department", new { id = responseMessage.Id });
            }
            catch (Exception ex)
            {
                ViewData["ServerError"] = ex.Message;
                return RedirectToAction("Edit", "Department", new { id = dep.Id });
            }
        }
コード例 #3
0
        public JsonResult GetDepartmentChief(int idDepartment)
        {
            string result = "--отсутствует--";
            var dep = new Department(idDepartment);
            if (dep.Chief != null && dep.Chief.Id > 0)
            {
                result = dep.Chief.DisplayName;
            }

            return Json(new { name = result });
        }
コード例 #4
0
        public ActionResult New(Department dep)
        {
            var user = DisplayCurUser();
            if (!user.UserCanEdit()) return RedirectToAction("AccessDenied", "Error");

            //Save department
            try
            {
                ResponseMessage responseMessage;
                //dep.Creator = new Employee(){AdSid = GetCurUser().Sid};
                bool complete = dep.Save(out responseMessage);
                if (!complete) throw new Exception(responseMessage.ErrorMessage);

                return RedirectToAction("Edit", "Department", new { id = responseMessage.Id });
            }
            catch (Exception ex)
            {
                ViewData["ServerError"] = ex.Message;
                return View("New", dep);
            }
        }
コード例 #5
0
ファイル: Department.cs プロジェクト: WakeDown/UnitApis
 private void FillSelf(Department dep)
 {
     Id = dep.Id;
     Name = dep.Name;
     ParentDepartment = dep.ParentDepartment;
     Chief = dep.Chief;
     EmployeeCount = dep.EmployeeCount;
     Creator = dep.Creator;
 }