public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (repo.Delete(id) == null) { return(HttpNotFound()); } return(View(repo.Delete(id))); }
private void tsbCancel_Click(object sender, EventArgs e) { if (formMode == FormMode.Add) { purchaseRepository.Delete(lblCode.Text); } GetLastPurchase(); DisableForm(); formMode = FormMode.View; this.Text = "Pembelian"; }
// GET: PurchasesController/Delete/5 public ActionResult Delete(int id) { var purchase = _repo.FindById(id); if (purchase == null) { return(NotFound()); } var IsSuccess = _repo.Delete(purchase); if (!IsSuccess) { return(BadRequest()); } return(RedirectToAction(nameof(Index))); }
public void Delete(Guid id, string purchaseCode) { Transaction tx = null; try { using (var em = EntityManagerFactory.CreateInstance(ds)) { tx = em.BeginTransaction(); var q = new Query().From(tableName).Delete().Where("ID").Equal("{" + id + "}"); em.ExecuteNonQuery(q.ToSql(), tx); purchaseRepository.Delete(em, tx, purchaseCode); tx.Commit(); } } catch (Exception ex) { tx.Rollback(); throw ex; } }
//删除采购单 public void DeletePurchase(PurchaseViewModel model) { var purchase = _purchaseRepository.FindBy(x => x.PurchaseId == model.PurchaseId).Include(z => z.PurchaseApplication.Item).FirstOrDefault(); if (purchase == null) { return; } var deletingPurchaseNumber = purchase.PurchaseNumber; purchase.PurchaseApplication.ProcessStatus = ProcessStatusEnum.申请审核中; purchase.PurchaseApplication.AuditStatus = AuditStatusEnum.未审批; purchase.Status = ProcessStatusEnum.申请审核中; _purchaseRepository.Delete(purchase); _purchaseRepository.Save(); PurchaseHeader purchaseHeader = _purchaseHeaderRepository.GetPurchaseHeader(deletingPurchaseNumber); if (purchaseHeader.Purchases == null || purchaseHeader.Purchases.Count == 0) { _purchaseHeaderRepository.Delete(purchaseHeader); _purchaseHeaderRepository.Save(); } }
/// <summary> /// Servicio que elimina una entidad Purchase (Purchase) dado su Id /// </summary> /// <param name="id">Id de la entidad a eliminar</param> /// <param name="user">Usuario que elimina la entidad</param> public virtual void Delete(int id, string user) { using (var dbContextScope = new TiendaDbContext()) { _repository.Delete(id, user); dbContextScope.SaveChanges(); } }
public async Task <IActionResult> DeleteConfirmed(string id) { var purchase = await _purchaseRepository.GetById(id); _purchaseRepository.Delete(purchase); await _unitOfWork.SaveChanges(); return(RedirectToAction(nameof(Index))); }
public bool DeletePurchase(int id) { var result = false; var purchase = _purchaseRepository.GetSingle(x => x.Id == id); if (purchase != null) { result = _purchaseRepository.Delete(purchase); } return(result); }
public void DeleteById(int id) { var album = AlbumRepository.GetById(id); ArtistRepository.DeleteIfNoAlbums(album.ArtistId); var tempPictures = album.Pictures.Select(x => new { Id = x.PictureId, Path = x.Path, FileName = x.FileName }).ToList(); foreach (var pic in tempPictures) { PictureService.Delete(pic.Path, pic.FileName); PictureRepository.Delete(pic.Id); } var tempPurchases = album.Purchases.ToList(); foreach (var purchase in tempPurchases) { PurchaseRepository.Delete(purchase.AlbumId, purchase.ProfileId); } AlbumRepository.Delete(album.AlbumId); }
public ActionResult CancelledProducts(List <ProductDetail> model) { string userId = User.Claims.First(c => c.Type == "UserID").Value; var allpurchases = _purchaserepository.GetAllPurchases().Where(x => x.UserId == userId).ToList(); foreach (var m in model) { if (m.Checked) { foreach (var a in allpurchases) { if (a.ProductId == m.Id) { _purchaserepository.Delete(a); } } } } return(Ok()); }
public async Task <PurchaseResponse> DeleteAsync(int id) { try { var purchase = await _purchaseRepository.FindByIdAsync(id); if (purchase == null) { return(new PurchaseResponse($"this purchase doesn't exists by id {id}")); } _purchaseRepository.Delete(purchase); await _unityOfWork.CompleteAsync(); return(new PurchaseResponse(purchase)); } catch (Exception e) { return(new PurchaseResponse($"An error occurred {e.Message}")); } }
public ActionResult Delete(int purchaseId) { _purchaseRepository.Delete(purchaseId, GetUserId()); return(Ok()); }
public void DeletePurchase(PurchaseEntity purchase) { purchaseRepository.Delete(purchase.ToDalPurchase()); uow.Commit(); }