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.")); } }
/// <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))); }
public async Task <HostModel> Delete(Guid id) { var entity = _repository.Delete(id); return(await Task.FromResult(entity.ToModel()).ConfigureAwait(false)); }