Exemplo n.º 1
0
        public void EditUserDetail(EditUserDetailViewModel model)
        {
            var        user       = _userService.GetUser();
            UserDetail userDetail = _userDetailRepository.Get(x => x.UserId == user.UserId);

            if (userDetail == null)
            {
                userDetail = new UserDetail();
                _userDetailRepository.Add(userDetail);
                userDetail.CreateDate = DateTime.Now;
            }
            else
            {
                userDetail.UpdateDate = DateTime.Now;
            }
            userDetail.UserId = user.UserId;
            if (model.ProfileImage != null)
            {
                userDetail.ProfileImage = model.ProfileImage;
            }
            userDetail.NameSurname      = model.NameSurname;
            userDetail.BirthDate        = model.BirthDate;
            userDetail.Gender           = model.Gender;
            userDetail.DrivingLicenseId = model.DrivingLicenseId;
            userDetail.NationalityId    = model.NationalityId;
            try
            {
                _userDetailRepository.SaveChanges();
            }
            catch (Exception ex)
            {
                var errorMessage = ex.Message;
                throw;
            }
        }