public ActionResult StopSale(int id) { int saleid = Convert.ToInt32(product.Get(id).SaleID); Product obj = product.Get(id); obj.SaleID = null; product.Update(obj); salerepo.Delete(saleid); return(Json("success")); }
public IActionResult Delete(int id) { var currentUser = GetCurrentUserProfile(); var sale = _saleRepo.GetById(id); if (currentUser.Id == sale.UserProfileId) { _saleRepo.Delete(id); return(NoContent()); } else { return(Unauthorized()); } }
public void Test_Delete_Sale() { var fakeContext = new FakeContext("Delete_Sale"); fakeContext.FillWith <Sale>(); using (var context = new MainContext(fakeContext.FakeOptions, fakeContext.FakeConfiguration().Object)) { var repository = new SaleRepository(context); var currentCount = context.Sales.Count(); Assert.Equal(5, currentCount); repository.Delete(1); Assert.Equal(4, context.Sales.Count()); } }
// GET: Reservation public ActionResult Seat(int movieID, int saloonID, int sessionID) { Session ses = _sesRep.FirstOrDefault(x => x.ID == sessionID); if (DateTime.Now <= ses.Time && DateTime.Now.AddMinutes(30) >= ses.Time) { List <Sale> list = _saleRep.Where(x => x.SaleType == ENTITIES.Enums.SaleType.Reservation && x.SessionID == sessionID); List <int> toBeUpdatedSeatsId; for (int i = 0; i < list.Count; i++) { int saleId = list[i].ID; toBeUpdatedSeatsId = _saleSeatRep.Where(x => x.SaleID == saleId).Select(x => x.SeatID).ToList(); foreach (int id in toBeUpdatedSeatsId) { Seat seat = _sRep.FirstOrDefault(x => x.ID == id); seat.SeatActive = false; _sRep.Update(seat); } _saleSeatRep.DeleteRange(_saleSeatRep.Where(x => x.SaleID == saleId)); _saleRep.Delete(list[i]); } } Session selectedSession = _sesRep.Find(sessionID); List <Seat> seats = _sRep.Where(x => x.SessionID == sessionID && x.SaloonID == saloonID); SeatVM svm = new SeatVM { //Tum koltuklari cek. Seats = seats, Price = selectedSession.Price }; TempData["movieID"] = movieID; TempData["saloonID"] = saloonID; TempData["sessionID"] = sessionID; TempData["sessionTime"] = ses.Time; return(View(svm)); }
public JsonResult Delete(int id) { return(Json(saleRepository.Delete(id), JsonRequestBehavior.AllowGet)); }
public bool Delete(int id) { return(_saleRepository.Delete(id)); }