public ActionResult Delete(int id) { try { _bookingService.Delete(id); return(NoContent()); } catch (Exception e) { return(BadRequest(e.Message)); } }
public void TestBookingOrderServiceDelete(long id, int addStart, int addEnd) { DateTime start = DateTime.Now.AddHours(addStart); DateTime end = DateTime.Now.AddHours(addEnd); UserInfo user = new UserInfo(); Product product = new Product(); BookingOrder boBeforeCreated = new BookingOrder() { Id = id, User = user, Product = product, StartTimeOfBooking = start, EndTimeOfBooking = end }; _mockRepo.Setup(x => x.Read(id)).Returns(new Queue <BookingOrder>(new[] { boBeforeCreated, null }).Dequeue); _mockRepo.Setup(x => x.Delete(boBeforeCreated)).Returns(boBeforeCreated); Assert.IsTrue(_service.Delete(id) != null); _mockRepo.Verify(x => x.Delete(It.IsAny <BookingOrder>()), Times.Once); }