示例#1
0
        public ActionResult ThemMoi()
        {
            var model = new ModelLichCongTac {
                Id = 0
            };

            if (User.IsInRole("Admin"))
            {
                IEnumerable <DropdownModel> category = _services.Dropdownlist(0, null, "DONVIPHONGKHOA", 1);
                ViewBag.ParentId = category.Select(x => new SelectListItem {
                    Text = x.Text, Value = x.Value.ToString()
                });
            }
            else
            {
                var um                  = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new ApplicationDbContext()));
                var user                = um.FindById(User.Identity.GetUserId());
                var _roleUser           = user.Roles.FirstOrDefault();
                ApplicationDbContext db = new ApplicationDbContext();
                var role                = db.Roles.Find(_roleUser.RoleId);
                var _Trained            = _servicesRoleFunction.GetByUserNameCode(role.Name, "TRAINED");
                IEnumerable <DropdownModel> category = _services.Dropdownlist2(_Trained.ChuyenMucId.GetValueOrDefault(), null, "DONVIPHONGKHOA", 1);
                ViewBag.ParentId = category.Select(x => new SelectListItem {
                    Text = x.Text, Value = x.Value.ToString()
                });
            }

            return(View(model));
        }
        public ActionResult Detail(int?Id)
        {
            ModelLichCongTac entity;

            if (Id.HasValue && Id > 0)
            {
                Content model = _services.GetById(Id.Value);
                entity = new ModelLichCongTac
                {
                    Id   = model.contentId,
                    Link = model.contentAlias,
                    Name = model.contentName,
                    Body = model.contentBody
                };
                ViewBag.Title = "Cập nhật lịch công tác toàn trường";
            }
            else
            {
                entity = new ModelLichCongTac
                {
                    Id = 0
                };
                ViewBag.Title = "Thêm mới lịch công tác toàn trường";
            }
            return(View(entity));
        }
示例#3
0
 public ActionResult ThemMoi(ModelLichCongTac model)
 {
     if (ModelState.IsValid)
     {
         Content entity = new Content
         {
             contentAlias      = model.Link,
             contentUpdateTime = DateTime.Now,
             contentParentId   = model.ParentId,
             contentName       = model.Name,
             contentCreateTime = DateTime.Now,
             contentBody       = model.Body,
             isTrash           = false,
             contentView       = 0,
             contentLanguageId = 1,
             contentKey        = "LICHCONGTAC",
             contentCreateUser = User.Identity.Name,
             contentUpdateUser = User.Identity.Name,
             isApproval        = true
         };
         _services.Add(entity);
         _services.Save();
         entity.contentAlias = entity.contentAlias + "-" + entity.contentId;
         _services.Update(entity);
         _services.Save();
         return(RedirectToAction("Index", new { _parentId = entity.contentParentId }));
     }
     if (User.IsInRole("Admin"))
     {
         IEnumerable <DropdownModel> category = _services.Dropdownlist(0, null, "DONVIPHONGKHOA", 1);
         ViewBag.ParentId = category.Select(x => new SelectListItem {
             Text = x.Text, Value = x.Value.ToString()
         });
     }
     else
     {
         var um                  = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new ApplicationDbContext()));
         var user                = um.FindById(User.Identity.GetUserId());
         var _roleUser           = user.Roles.FirstOrDefault();
         ApplicationDbContext db = new ApplicationDbContext();
         var role                = db.Roles.Find(_roleUser.RoleId);
         var _Trained            = _servicesRoleFunction.GetByUserNameCode(role.Name, "TRAINED");
         IEnumerable <DropdownModel> category = _services.Dropdownlist2(_Trained.ChuyenMucId.GetValueOrDefault(), null, "DONVIPHONGKHOA", 1);
         ViewBag.ParentId = category.Select(x => new SelectListItem {
             Text = x.Text, Value = x.Value.ToString()
         });
     }
     return(View(model));
 }
 public ActionResult Detail(ModelLichCongTac model)
 {
     if (ModelState.IsValid)
     {
         if (model.Id > 0)
         {
             Content entity = _services.GetById((int)model.Id);
             entity.contentAlias      = model.Link;
             entity.contentUpdateTime = DateTime.Now;
             entity.contentParentId   = model.ParentId;
             entity.contentBody       = model.Body;
             entity.contentName       = model.Name;
             entity.contentUpdateUser = User.Identity.Name;
             _services.Update(entity);
             _services.Save();
         }
         else
         {
             Content entity = new Content
             {
                 contentAlias      = model.Link,
                 contentUpdateTime = DateTime.Now,
                 contentParentId   = model.ParentId,
                 contentName       = model.Name,
                 contentCreateTime = DateTime.Now,
                 contentBody       = model.Body,
                 isTrash           = false,
                 contentView       = 0,
                 contentLanguageId = 1,
                 contentKey        = "LICHCONGTACTOANTRUONG",
                 contentCreateUser = User.Identity.Name,
                 contentUpdateUser = User.Identity.Name,
                 isApproval        = true
             };
             _services.Add(entity);
             _services.Save();
             entity.contentAlias = entity.contentAlias + "-" + entity.contentId;
             _services.Update(entity);
             _services.Save();
         }
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
示例#5
0
 public ActionResult CapNhat(ModelLichCongTac model)
 {
     if (ModelState.IsValid)
     {
         Content entity = _services.GetById((int)model.Id);
         entity.contentAlias      = model.Link;
         entity.contentUpdateTime = DateTime.Now;
         entity.contentParentId   = model.ParentId;
         entity.contentBody       = model.Body;
         entity.contentName       = model.Name;
         entity.contentUpdateUser = User.Identity.Name;
         _services.Update(entity);
         _services.Save();
         return(RedirectToAction("Index", new { _parentId = entity.contentParentId }));
     }
     if (User.IsInRole("Admin"))
     {
         IEnumerable <DropdownModel> category = _services.Dropdownlist(0, (int)model.Id, "DONVIPHONGKHOA", 1);
         ViewBag.ParentId = category.Select(x => new SelectListItem {
             Text = x.Text, Value = x.Value.ToString()
         });
     }
     else
     {
         var um                  = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(new ApplicationDbContext()));
         var user                = um.FindById(User.Identity.GetUserId());
         var _roleUser           = user.Roles.FirstOrDefault();
         ApplicationDbContext db = new ApplicationDbContext();
         var role                = db.Roles.Find(_roleUser.RoleId);
         var _Trained            = _servicesRoleFunction.GetByUserNameCode(role.Name, "TRAINED");
         IEnumerable <DropdownModel> category = _services.Dropdownlist2(_Trained.ChuyenMucId.GetValueOrDefault(), (int)model.Id, "DONVIPHONGKHOA", 1);
         ViewBag.ParentId = category.Select(x => new SelectListItem {
             Text = x.Text, Value = x.Value.ToString()
         });
     }
     return(View(model));
 }