示例#1
0
        public object AddPermissionToRole(int RoleId, int PermissionId)
        {
            if (RoleId == 0 || PermissionId == 0)
            {
                return(BadRequest("Values for PermissionId and RoleId are required.  Please verify your data."));
            }

            try
            {
                ROLE_PERMISSION result = _service.AddPermissionToRole(RoleId, PermissionId);
                log.Info(string.Format("User {2} has added New RoleId: {0} association to PermissionId: {1}", RoleId, PermissionId, "FOPS"));
                return(Ok(result));
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    StringBuilder errmsg = new StringBuilder();

                    errmsg.Append(string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                                eve.Entry.Entity.GetType().Name, eve.Entry.State.ToString()));
                    foreach (var ve in eve.ValidationErrors)
                    {
                        errmsg.Append(string.Format("- Property: \"{0}\", Error: \"{1}\"",
                                                    ve.PropertyName, ve.ErrorMessage));
                    }
                    log.Error(e);
                }
                return(BadRequest("netApi.Controller.AddRoleToUser(int, int) caused DbEntityValidationException!"));
            }
            catch (Exception e)
            {
                var msg = string.Format("Error creating new User/Role association.\n\nPermissionId:\n{0}, RoleId: {1}.\n\n{2}", PermissionId, RoleId, e.Message);
                log.Error(e);

                return(BadRequest(msg));
            }
        }
示例#2
0
 public void ApplyProjectionPropertiesToEntityCallBack(ROLE_PERMISSIONInfo ROLEPERMISSIONInfo, ROLE_PERMISSION ROLEPERMISSION)
 {
     DataUtils.ShallowCopy(ROLEPERMISSION, ROLEPERMISSIONInfo, false);
 }