示例#1
0
 private string GetOwnerName(UserProfileData user)
 {
     if (string.IsNullOrEmpty(user.FirstName) || string.IsNullOrEmpty(user.LastName))
     {
         return user.UserName;
     }
     else
     {
         return $"{user.FirstName} {user.LastName}";
     }
 }
示例#2
0
        public CommonResult<UserProfileData> UpdateUserProfile(string userName, UserProfileData requestData)
        {
            using (var context = ContextFactory.GetDbContext(_dbConfiguration))
            {
                var user = context.Users.First(x => x.UserName == userName);
                user.FirstName = requestData.FirstName;
                user.LastName = requestData.LastName;
                user.Email = requestData.Email;

                context.SaveChanges();

                var mapped = Mapper.Map<UserProfileData>(user);
                mapped.ProfileImagePath = GenerateImagePath(user.ImageName);

                return CommonResult<UserProfileData>.Success(mapped);
            }
        }