public static Recipient Map(Recipient recipientForUpdate, RecipientUpdateInputDtoModel dtoModel)
        {
            recipientForUpdate.FirstName     = dtoModel.FirstName;
            recipientForUpdate.LastName      = dtoModel.LastName;
            recipientForUpdate.RecipientTown = dtoModel.RecipientTown;
            recipientForUpdate.Address       = dtoModel.Address;
            recipientForUpdate.Phone         = dtoModel.Phone;

            return(recipientForUpdate);
        }
Пример #2
0
        public static RecipientUpdateInputDtoModel Map(RecipientUpdateInputViewModel viewModel)
        {
            var dtoModel = new RecipientUpdateInputDtoModel
            {
                RecipientId   = viewModel.RecipientId,
                FirstName     = viewModel.FirstName,
                LastName      = viewModel.LastName,
                RecipientTown = viewModel.RecipientTown,
                Address       = viewModel.Address,
                Phone         = viewModel.Phone
            };

            return(dtoModel);
        }
Пример #3
0
        /// <summary>
        /// update recipient in datbase
        /// </summary>
        /// <param name="dtoModel"></param>
        /// <returns></returns>
        public async Task <bool> UpdateRecipientAsync(RecipientUpdateInputDtoModel dtoModel)
        {
            var recipientForUpdate = await this.recipients.All().FirstOrDefaultAsync(x => x.Id == dtoModel.RecipientId);

            if (recipientForUpdate.Id == dtoModel.RecipientId &&
                recipientForUpdate.FirstName == dtoModel.FirstName &&
                recipientForUpdate.LastName == dtoModel.LastName &&
                recipientForUpdate.RecipientTown == dtoModel.RecipientTown &&
                recipientForUpdate.Address == dtoModel.Address &&
                recipientForUpdate.Phone == dtoModel.Phone)
            {
                return(false);
            }

            recipientForUpdate = RecipientUpdateServiceMapper.Map(recipientForUpdate, dtoModel);

            this.recipients.Update(recipientForUpdate);
            await this.recipients.SaveAsync();

            return(true);
        }