Exemplo n.º 1
0
        public static RecipientDeleteDtoModel Map(RecipientDeleteViewModel viewModel)
        {
            var dtoModel = new RecipientDeleteDtoModel
            {
                RecipientId = viewModel.RecipientId
            };

            return(dtoModel);
        }
Exemplo n.º 2
0
        /// <summary>
        /// find recipient by id and delete it from database
        /// </summary>
        /// <param name="deleteDtoModel"></param>
        /// <returns></returns>
        public async Task <bool> DeleteRecipientAsync(RecipientDeleteDtoModel deleteDtoModel)
        {
            var modelToDelete = await this.recipients.All().FirstAsync(x => x.Id == deleteDtoModel.RecipientId);

            if (modelToDelete == null)
            {
                return(false);
            }

            await this.orderService.DeleteAllOrdersByRecipientIdAsync(modelToDelete.Id);

            this.recipients.Delete(modelToDelete);
            await this.recipients.SaveAsync();

            return(true);
        }