Example #1
0
        public ActionConfirmation Delete(int id)
        {
            Host hostToDelete = _hostRepository.Get(id);

            if (hostToDelete != null)
            {
                _hostRepository.Delete(hostToDelete);

                try
                {
                    _hostRepository.DbContext.CommitChanges();

                    return(ActionConfirmation.CreateSuccessConfirmation(
                               "The host was successfully deleted."));
                }
                catch
                {
                    _hostRepository.DbContext.RollbackTransaction();

                    return(ActionConfirmation.CreateFailureConfirmation(
                               "A problem was encountered preventing the host from being deleted. " +
                               "Another item likely depends on this host."));
                }
            }
            else
            {
                return(ActionConfirmation.CreateFailureConfirmation(
                           "The host could not be found for deletion. It may already have been deleted."));
            }
        }
Example #2
0
        /// <summary>
        /// The method deletes product from database
        /// </summary>
        /// <param name="check">Models.Check check</param>
        /// <returns></returns>
        public Task <bool> DeleteProduct(Models.Product product)
        {
            Device device = new Device {
                Id = product.Id
            };
            Image image = new Image {
                Id = product.Images.Id
            };
            Product prod = new Product {
                Id = product.Id
            };

            return(Task.FromResult(Repository.Delete(prod, device, image)));
        }
Example #3
0
        public async Task <HostModel> Delete(Guid id)
        {
            var entity = _repository.Delete(id);

            return(await Task.FromResult(entity.ToModel()).ConfigureAwait(false));
        }