예제 #1
0
        public async Task <IActionResult> Create(UserCreateModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(ResultDto.Err("数据验证失败;" + GetErrorFromModelStateStr())));
            }
            var user = model.MapTo <User>();

            user.Password = CompanyName.ProjectName.Core.Security.MD5Encrypt.MD5(user.Password);
            if (!string.IsNullOrWhiteSpace(user.Avatar))
            {
                var saveUrl = IMGOperate.BaseSave(ImagePathType.员工头像, user.Avatar);
                user.Avatar = saveUrl;
            }
            var r = await UserApp.InsertAsync(user, await CurrentUser());

            return(Json(r));
        }
 public static CreateUserCommand ToCreateUserCommand(this UserCreateModel model)
 {
     return(model.MapTo <UserCreateModel, CreateUserCommand>());
 }