Exemplo n.º 1
0
 public bool UpdateUserTypeRoles(UserTypeRoles model)
 {
     using (EFUserTypeRolesRepository _rsp = new EFUserTypeRolesRepository())
     {
         return(_rsp.UpdateUserTypeRoles(model));
     }
 }
Exemplo n.º 2
0
        public IHttpActionResult Post([FromBody] Request <UserTypeRoles> req)
        {
            try
            {
                UserTypeRoles model  = req.Data as UserTypeRoles;
                UserInfo      user   = _user.GetCurrentUser();
                Role          role   = _role.Get(model.RoleId);
                bool          result = false;
                if (string.IsNullOrEmpty(model.UserTypeRoleId))
                {
                    model.CreateDateTime = DateTime.Now;
                    model.CreateUserId   = user.UserId;
                    model.CreateUserName = user.PatientInfo == null ? user.LoginName : user.PatientInfo.NAME;
                    model.EditDateTime   = DateTime.Now;
                    model.EditUserId     = user.UserId;
                    model.EditUserName   = user.PatientInfo == null ? user.LoginName : user.PatientInfo.NAME;
                    model.RoleName       = role.RoleName;
                    model.UserTypeRoleId = Guid.NewGuid().ToString();
                    result = _utr.AddUserTypeRoles(model);
                }
                else
                {
                    model.EditDateTime = DateTime.Now;
                    model.EditUserId   = user.UserId;
                    model.EditUserName = user.PatientInfo == null ? user.LoginName : user.PatientInfo.NAME;
                    model.RoleName     = role.RoleName;
                    result             = _utr.UpdateUserTypeRoles(model);
                }
                if (!result)
                {
                    return(BadRequest("操作失败"));
                }

                Response <string> rsp = new Response <string> ();
                rsp.Data = "操作成功";
                return(Ok(rsp));
            }
            catch (Exception ex)
            {
                LogService.WriteErrorLog("UserTypeController[Post]", ex.ToString());
                return(BadRequest(ex.Message));
            }
        }
        protected CTMS_SYS_USERTYPEROLES LoadEntityFromModel(UserTypeRoles model)
        {
            if (model == null)
            {
                return(null);
            }

            CTMS_SYS_USERTYPEROLES entity = new CTMS_SYS_USERTYPEROLES();

            entity.USERTYPEROLEID = model.UserTypeRoleId;
            entity.USERTYPE       = model.UserType;
            entity.ROLEID         = model.RoleId;
            entity.ROLENAME       = model.RoleName;
            entity.CREATEUSERID   = model.CreateUserId;
            entity.CREATEUSERNAME = model.CreateUserName;
            entity.CREATEDATETIME = model.CreateDateTime;
            entity.EDITUSERID     = model.EditUserId;
            entity.EDITUSERNAME   = model.EditUserName;
            entity.EDITDATETIME   = model.EditDateTime;
            return(entity);
        }
        protected UserTypeRoles LoadModelFromEntity(CTMS_SYS_USERTYPEROLES entity)
        {
            if (entity == null)
            {
                return(null);
            }

            UserTypeRoles model = new UserTypeRoles();

            model.UserTypeRoleId = entity.USERTYPEROLEID;
            model.UserType       = (int)entity.USERTYPE;
            model.RoleId         = entity.ROLEID;
            model.RoleName       = entity.ROLENAME;
            model.CreateUserId   = entity.CREATEUSERID;
            model.CreateUserName = entity.CREATEUSERNAME;
            model.CreateDateTime = (DateTime)entity.CREATEDATETIME;
            model.EditUserId     = entity.EDITUSERID;
            model.EditUserName   = entity.EDITUSERNAME;
            model.EditDateTime   = (DateTime)entity.EDITDATETIME;
            return(model);
        }
 public bool UpdateUserTypeRoles(UserTypeRoles model)
 {
     return(Update(LoadEntityFromModel(model)));
 }
 public bool AddUserTypeRoles(UserTypeRoles model)
 {
     return(Insert(LoadEntityFromModel(model)));
 }