Пример #1
0
 public AccessCode Update(GroupEditDTO groupDTO, UserDTO userDTO)
 {
     using (var Data = DataFactory.Get())
     {
         var check = CheckRule(userDTO, groupDTO.Id, GroupRule.CanEdit, Data);
         if (check.Code == AccessCode.Succsess)
         {
             EditGroup(groupDTO, check.Group);
             Data.GroupRepository.Edited(check.Group);
             Data.SaveChanges();
         }
         return(check.Code);
     }
 }
Пример #2
0
 public CreateResultDTO Create(GroupEditDTO groupDTO, UserDTO userDTO)
 {
     using (var Data = DataFactory.Get())
     {
         var user = getUserService.Get(userDTO, Data);
         if (GroupRule.CanCreate(user))
         {
             var group = new Group();
             EditGroup(groupDTO, group);
             Data.GroupRepository.Add(group);
             Data.SaveChanges();
             return(new CreateResultDTO(group.Id, AccessCode.Succsess));
         }
     }
     return(CreateResultDTO.NoPremision);
 }
Пример #3
0
        public IActionResult Create(GroupRequest groupRequest)
        {
            var groupDTO = new GroupEditDTO
            {
                Name = groupRequest.Name,
                Open = groupRequest.Open,
                Logo = groupRequest.Logo
            };
            var res = GroupService.Create(groupDTO, GetUser());

            if (res.Code == AccessCode.Succsess)
            {
                return(RedirectToAction("Index", new { id = res.Id }));
            }
            else
            {
                return(Redirect(res.Code));
            }
        }
Пример #4
0
        public IActionResult Update(GroupRequest groupRequest)
        {
            var section = new GroupEditDTO
            {
                Name = groupRequest.Name,
                Open = groupRequest.Open,
                Id   = groupRequest.Id,
                Logo = groupRequest.Logo
            };
            var res = GroupService.Update(section, GetUser());

            if (res == AccessCode.Succsess)
            {
                return(RedirectToAction("Index", new { id = groupRequest.Id }));
            }
            else
            {
                return(Redirect(res));
            }
        }
Пример #5
0
 private void EditGroup(GroupEditDTO groupDTO, Group group)
 {
     group.Logo = groupDTO.Logo;
     group.Name = groupDTO.Name;
     group.Open = groupDTO.Open;
 }