コード例 #1
0
ファイル: EmployeeController.cs プロジェクト: galyna/Toloka
        public ActionResult EditDetails(DetailsModel model)
        {
            User user = UserRepository.Get(u => u.UserName == User.Identity.Name).SingleOrDefault();
            if (user != null && user.Role.IsAdmin || user.Role.IsAuthor)
            {

                try
                {
                    Employee employee = EmployeeRepository.Get(s => s.Id.Equals(model.Id)).SingleOrDefault();
                    employee.HtmlDetail = Server.HtmlEncode(model.HtmlDetail);
                    EmployeeRepository.SaveOrUpdate(employee);

                    return RedirectToAction("Edit", "Employee", new { id = model.Id });
                }
                catch
                {
                    return View(model);
                }
            }

            return null;
        }
コード例 #2
0
ファイル: EmployeeController.cs プロジェクト: galyna/Toloka
        public ActionResult EditDetails(int id)
        {
            User user = UserRepository.Get(u => u.UserName == User.Identity.Name).SingleOrDefault();
            if (user != null && user.Role.IsAdmin || user.Role.IsAuthor)
            {
                string html = HttpUtility.HtmlDecode(EmployeeRepository.Get(s => s.Id == id).SingleOrDefault().HtmlDetail);
                DetailsModel model = new DetailsModel();
                model.Id = id;
                model.HtmlDetail = html != null ? html : "";
                return View(model);
            }

            return null;
        }