public void GenerateInvoice() { long customerId = _customerService.GetAll().FirstOrDefault().Id; long parkingId = _parkingService.GetAll().FirstOrDefault().Id; ParkedDTO p = new ParkedDTO(); p.inTime = DateTime.Now; p.outTime = DateTime.Now.AddHours(3); p.customerId = customerId; p.parkingId = parkingId; _parkedService.Create(p); _customerService.GenerateInvoice(customerId); var invoices = _customerService.GetById(customerId).Invoices.Count(); Assert.Equal(1, invoices); }
public IActionResult Create([FromBody] ParkedDTO parkedDTO) { if (parkedDTO == null) { return(BadRequest()); } try { Parked parked = _service.Create(parkedDTO); return(CreatedAtRoute("GetParked", new { id = parked.Id }, parked)); } catch (Exception e) { return(BadRequest(e.Message)); } }