public async Task Remove(Guid id) { if (_vendorRepository.GetVendorProducsAddress(id).Result.Products.Any()) { Notification("The Vendor has Products linked to its"); return; } await _vendorRepository.Delete(id); }
public async Task <IActionResult> DeleteConf(int ID) { var ven = await vendorRepo.GetVendorByID(ID); vendorRepo.Delete(ven); await vendorRepo.Save(); return(RedirectToAction(nameof(Index))); }
public ActionResult Delete(int id) { var apiResult = TryExecute(() => { _vendorRepository.Delete(id); _unitOfWork.Commit(); return(true); }, "Vendor deleted sucessfully"); return(Json(apiResult, JsonRequestBehavior.AllowGet)); }
//public bool UpdatePatch(JsonPatchDocument<UpdatePatchDTO> dTO, int id) //{ // bool result = false; // var TagList = new List<Tag>(); // foreach (var item in dTO.ApplyTo(UpdatePatchDTO)) // { // Tag tag = new Tag(); // tag.NameTag = item.NameTag; // TagList.Add(tag); // } // var ven = _repository.GetByIdVender(id); // ven.VendorName = dto.VendorName; // ven.Title = dto.Title; // ven.PhoneNumber = dto.PhoneNumber; // ven.Address = dto.Address; // ven.Tag = TagList; // var resultvendor = _repository.UpdateVendor(ven); // result = true; // if (resultvendor > 0) // { // result = true; // } // return result; //} public bool Delete(int id) { var iddelete = _repository.GetByIdVendorDelete(id); var result = _repository.Delete(iddelete); if (result > 0) { return(true); } return(true); }
public async Task Delete(Guid userId, Guid id) { var vendor = await _vendorRepository.Delete(userId, id); if (vendor == null) { throw new KeyNotFoundException($"Vendor with id: {id} not found."); } await _vendorRepository.CommitAsync(); }
public bool Delete(int id) { bool result = false; int deleted = _VendorRepository.Delete(id); if (deleted > 0) { result = true; } return(result); }
public IActionResult Delete(EntityViewModel vm) { bool errorMessageSet = false; var userID = User.FindFirstValue(ClaimTypes.NameIdentifier); //Check for absorption vendor selection. if (vm.AbsorptionEntity.EntityID != 0) { //Make sure the user owns both the absorbed and absorbing vendors if (!_vendorRepository.UserOwnsVendor(vm.EntityOfInterest.EntityID, userID) || !_vendorRepository.UserOwnsVendor(vm.AbsorptionEntity.EntityID, userID)) { //TODO: Perhaps a more specific message to the user? return(NotFound()); } //Convert the VMVendors to DBVendors Vendor absorbedVendor = _vendorRepository.Get(vm.EntityOfInterest.EntityID, userID); Vendor absorbingVendor = _vendorRepository.Get(vm.AbsorptionEntity.EntityID, userID); //Ensure that the deleted vendor is not default. if (!absorbedVendor.IsDefault) { //Make sure the absorbing vendor and the deleting vendor are not the same. if (absorbedVendor.VendorID != absorbingVendor.VendorID) { //Update all transactions that currently point to the vendor being deleted to instead point to the absorbing vendor. _vendorRepository.Absorption(absorbedVendor.VendorID, absorbingVendor.VendorID, userID); //Delete the vendor to be deleted. _vendorRepository.Delete(absorbedVendor.VendorID); TempData["Message"] = "Vendor successfully deleted."; return(RedirectToAction("Index")); } SetErrorMessage(vm, "Vendor being deleted and vendor absorbing cannot be the same.", errorMessageSet); errorMessageSet = true; } SetErrorMessage(vm, "Deleting a default vendor is not allowed.", errorMessageSet); errorMessageSet = true; } SetErrorMessage(vm, "You must select a vendor to absorb transactions related to the vendor being deleted.", errorMessageSet); EntityViewModel failureStateVM = new EntityViewModel(); failureStateVM.EntityOfInterest = vm.EntityOfInterest; failureStateVM.VendorSelectList = failureStateVM.InitVendorSelectList(_vendorRepository, userID); return(View(failureStateVM)); }
/// <summary> /// Delete vendor by id /// </summary> /// <param name="vendorId"></param> /// <returns>True if vendor can be deleted, false if cannot because it is connected with invoice</returns> public bool Delete(int vendorId) { var invoices = _vendorInvoiceRepository.GetInvocesByVendorId(vendorId); if (invoices != null && invoices.Count > 0) //if vendor is connected with at least one invoice, return false { return(false); } else { var vendor = _vendorRepository.GetById(vendorId); if (vendor != null) { _vendorRepository.Delete(vendor); _vendorRepository.SaveChanges(); return(true); } return(true); } }
public async Task <IActionResult> Delete(string code) { try { var isDeleted = await _vendorRepository.Delete(code); if (isDeleted) { return(Ok("Vendor Deleted!")); } else { return(Ok("Some error occured")); } } catch (ArgumentNullException) { return(Conflict("Vendor Not Present.")); } }
public async Task <bool> Remove(Guid id) { if (_vendorRepository.GetVendorProducsAddress(id).Result.Products.Any()) { Notification("The Vendor has Products linked to its"); return(false); } var vendor = await _vendorRepository.GetVendorAddress(id); var address = await _addressRepository.GetById(vendor.Address.Id); if (address != null) { await _addressRepository.Delete(vendor.Address.Id); } await _vendorRepository.Delete(id); return(true); }
public void Delete(Guid id) { _vendorRepository.Delete(id); }
public void Delete(VendorDto vendor) { repository.Delete(vendor); }
public bool Delete(Guid VendorId) { return(vendorRepository.Delete(VendorId)); }
public void DeleteVendor(VendorDto vendorDto) { vendorRepository.Delete(vendorDto.MappingVendor()); }
public async Task <ActionResult <Vendor> > DeleteVendor(int id) { await _vendorRepository.Delete(id); return(NoContent()); }
public async Task <int> Delete(int id) { var iddelete = _repository.GetByIdVendorDelete(id); return(await _repository.Delete(iddelete)); }