Exemplo n.º 1
0
 public UserDTO Update(UserDTO entity)
 {
     User _user = uow.UserRepo.GetByID(entity.Id);
     _user.Update(entity, uow);
     uow.UserRepo.Update(_user);
     uow.Commit();
     return DTOService.ToDTO<User, UserDTO>(_user);
 }
Exemplo n.º 2
0
 public UserDTO Add(UserDTO userToAdd)
 {
     User _user = new User();
     _user.Update(userToAdd, uow);
     uow.UserRepo.Insert(_user);
     uow.Commit();
     return DTOService.ToDTO<User, UserDTO>(_user);
 }
Exemplo n.º 3
0
 private static void CreateNewPhoneNumbers(User destination, UserDTO source)
 {
     source.PhoneNumbers.Where(x => x.IsNew()).ToList().ForEach(newPhoneNumber =>
     {
         var toDomain = new PhoneNumber();
         toDomain.Update(newPhoneNumber);
         destination.PhoneNumbers.Add(toDomain);
     });
 }
Exemplo n.º 4
0
 private static void RefreshExistingPhoneNumbers(User destination, UserDTO source, IRepository<PhoneNumber> phoneNumberRepository)
 {
     source.PhoneNumbers.Where(x => !x.IsNew()).ToList().ForEach(updatedPhoneNumber =>
     {
         var domainPhoneNumber = destination.PhoneNumbers.FirstOrDefault(x => x.Id == updatedPhoneNumber.Id);
         if (domainPhoneNumber == null)
         {
             throw new ArgumentNullException("You trying to update phone number which is actually doesn't exists in database");
         }
         if (updatedPhoneNumber.ShouldBeRemoved())
         {
             phoneNumberRepository.Delete(updatedPhoneNumber.Id);
         }
         else
         {
             domainPhoneNumber.Update(updatedPhoneNumber);
         }
     });
 }
Exemplo n.º 5
0
        public static void Update(this User destination, UserDTO source, IUnitOfWork uow)
        {
            destination.State = source.State;

            destination.FirstName = source.FirstName;
            destination.MiddleName = source.MiddleName;
            destination.LastName = source.LastName;
            destination.isMale = source.isMale;
            destination.BirthDate = source.BirthDate;
            destination.Email = source.Email;
            destination.Skype = source.Skype;
            destination.Login = source.Login;
            destination.Password = source.Password;
            destination.RoleId = source.RoleId;
            destination.CityId = source.CityId;

            PerformPhotoSaving(destination, source, uow.FileRepo);
            PerformPhoneNumbersSaving(destination, source, uow.PhoneNumberRepo);
        }
Exemplo n.º 6
0
 private static void PerformPhotoSaving(User destination, UserDTO source, IRepository<File> fileRepository)
 {
     var photoInDTO = source.Photo;
     if (photoInDTO != null)
     {
         var photoInDb = fileRepository.GetByID(source.Photo.Id);
         if (photoInDb == null)
         {
             throw new Exception("Database doesn't contains such entity");
         }
         if (photoInDTO.ShouldBeRemoved())
         {
             fileRepository.Delete(photoInDb.Id);
         }
         else
         {
             photoInDb.Update(photoInDTO);
             destination.Photo = photoInDb;
         }
     }
 }
Exemplo n.º 7
0
 public string getIdKUserByIdUser(UserDTO uDTO)
 {
     string sql = "Select USERS.IdKUser From USERS Where Name ='" + uDTO.Name + "'";
     return dp.getStrByString(sql, "IdKUser");
 }
 public string getIdKUserByIdUser(UserDTO uDTO)
 {
     return new UserDAO().getIdKUserByIdUser(uDTO);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Registers user with provided data
 /// </summary>
 /// <param name="model">User data</param>
 /// <returns>Updated user data</returns>
 public UserDTO Register(UserDTO model)
 {
     UserDTO modelResult = _userService.Add(model);
     return modelResult;
 }
Exemplo n.º 10
0
 private static void PerformPhoneNumbersSaving(User destination, UserDTO source, IRepository<PhoneNumber> phoneNumberRepository)
 {
     RefreshExistingPhoneNumbers(destination, source, phoneNumberRepository);
     CreateNewPhoneNumbers(destination, source);
 }