Пример #1
0
        public OperationResult AddFuncToGroup(long funcId, long usrGroupId, FuncAccessType accessType)
        {
            try
            {
                var dbContext = new AlohaDb();

                var result = dbContext.UserGroupAccesses.FirstOrDefault(uga => uga.UserFuncId == funcId && uga.UserGroupId == usrGroupId);

                if (result != null)
                {
                    return(new OperationResult
                    {
                        Success = false,
                        ErrorMessage = "Func already presemted in this group"
                    });
                }

                var newLink =
                    dbContext.UserGroupAccesses.Add(
                        new Entities.UserGroupAccess
                {
                    AccessId    = (int)accessType,
                    UserFuncId  = funcId,
                    UserGroupId = usrGroupId
                });

                dbContext.SaveChanges();

                return(new OperationResult
                {
                    Success = true,
                    CreatedObjectId = newLink.Id
                });
            }
            catch (Exception e)
            {
                log.Error("Error", e);
                return(new OperationResult
                {
                    Success = false,
                    ErrorMessage = e.Message
                });
            }
        }
Пример #2
0
 public OperationResult AddFuncToGroup(long funcId, long usrGroupId, FuncAccessType accessType)
 {
     return(userGroupService.AddFuncToGroup(funcId, usrGroupId, accessType));
 }