public ActionResult <OrderdCars> CheckOutOrder([FromBody] CheckOutOrder value) //public String CheckOutOrder([FromBody] CheckOutOrder value) { //return value.OrderCarID.ToString() + ',' + value.CustomerID.ToString(); OrderdCarsRepository oc = new OrderdCarsRepository(); OrderdCars currentOrderCar = oc.FindById(value.OrderCarID); if (currentOrderCar != null) { if ((currentOrderCar.Status == 2) && (currentOrderCar.CustomerID == value.CustomerID)) { DateTime startDT = (DateTime)currentOrderCar.StarteDT; TimeSpan ts = DateTime.Now.AddSeconds(-20) - startDT; double total = Math.Round(ts.TotalMinutes * currentOrderCar.Car.CarModel.PricePerMin, 1); currentOrderCar.Status = 3; currentOrderCar.EndDT = DateTime.Now; currentOrderCar.Total = (float)total; oc.Dispose(); CarRepository cr = new CarRepository(); Car currentCar = cr.FindById(currentOrderCar.CarID); currentCar.Status = 0; cr.Dispose(); return(currentOrderCar); } } return(null); }
public int GetSecondsIntervalBetweenStartAndNow(int id) { OrderdCarsRepository oc = new OrderdCarsRepository(); OrderdCars currentOrderCar = oc.FindById(id); DateTime startDT = (DateTime)currentOrderCar.StarteDT; TimeSpan ts = DateTime.Now - startDT; return(Convert.ToInt32(Math.Round(ts.TotalSeconds, 0))); }
public ActionResult <OrderdCars> Post([FromBody] ReserverCar value) { CarRepository cr = new CarRepository(); cr.UpdateStatusByCarID(1, value.CarID); Helper.Helper helper = new Helper.Helper(); var orderCar = new OrderdCars { Status = 1, CreateDT = DateTime.Now, ValidityDT = DateTime.Now.AddMinutes(20), PinkCode = helper.GetPinkCode().ToString(), CustomerID = value.CustomerID, CarID = value.CarID }; OrderdCarsRepository oc = new OrderdCarsRepository(); oc.Add(orderCar); oc.Dispose(); return(orderCar); }
public ActionResult <TryPayment> TryPayment(int id) { OrderdCarsRepository oc = new OrderdCarsRepository(); OrderdCars currentOrderCar = oc.FindById(id); DateTime startDT = (DateTime)currentOrderCar.StarteDT; TimeSpan ts = DateTime.Now - startDT; if (currentOrderCar.Status == 2) { TryPayment result = new TryPayment { EndDT = DateTime.Now, Total = Math.Round(ts.TotalMinutes * currentOrderCar.Car.CarModel.PricePerMin, 1) }; return(result); } else { return(null); } }
public bool Unlock([FromBody] UnlockCar value) { OrderdCarsRepository oc = new OrderdCarsRepository(); CarRepository cr = new CarRepository(); OrderdCars currentOrder = oc.FindByCarIdAndPinkCode(value.CarID, value.PinkCode); //return currentOrder; if (!(currentOrder == null)) { if (currentOrder.PinkCode == value.PinkCode) { currentOrder.Status = 2; currentOrder.StarteDT = DateTime.Now; oc.Dispose(); Car currentCar = cr.FindById(value.CarID); currentCar.Status = 2; cr.Dispose(); return(true); } } return(false); }
public IEnumerable <OrderdCars> OrdersByCustomer(int id) { OrderdCarsRepository oc = new OrderdCarsRepository(); return(oc.GetOrderCarsByCustomerId(id)); }