コード例 #1
0
        public void Edit(EditedUserProfileModel model)
        {
            var user = _systemUserRepository
                       .GetFirstOrDefault(predicate: a => a.SystemUserId == model.SystemUserId,
                                          include: a => a.Include(b => b.Business).Include(c => c.EduUser));

            if (user == null)
            {
                throw new ApplicationException("System user id is invalid");
            }

            user.FirstName = model.FirstName;
            user.LastName  = model.LastName;
            user.FullName  = $"{model.FirstName} {model.LastName}";

            var eduUser = user.EduUser.SingleOrDefault();

            eduUser.PreferredName = model.PreferredName;
            eduUser.Gender        = model.Gender;
            _eduUserRepository.Update(eduUser);

            user.MobilePhone = model.Mobilephone;
            user.WorkPhone   = model.Workphone;

            if (!string.IsNullOrEmpty(model.ProfilePhoto))
            {
                var textAsBytes = Convert.FromBase64String(model.ProfilePhoto);
                user.ProfilePhoto = textAsBytes;
            }

            _systemUserRepository.Update(user);
            _unitOfWork.SaveChanges();
        }
コード例 #2
0
ファイル: UserController.cs プロジェクト: wangshifeng/mentifi
 public IActionResult Edit([FromBody] EditedUserProfileModel model)
 {
     _userProfileService.Edit(model);
     return(Ok(MessageHelper.Success("The profile has been updated.")));
 }