public async Task <IActionResult> ScheduleCarWash(long id, [FromBody] CarWashModel model) { if (!(await CheckCarExistsById(id))) { return(NotFound()); } await _carsRepository.LogCarWash(id, model.AppointmentDate); return(Ok()); }
public CarWash AddNewCarWashByCarWashModel(CarWashModel model) { try { var add = new CarWash { IsDeleted = false, CreatedById = model.CreatedById, Total = model.Total, CreatedDate = model.CreatedDate, Date = model.Date, Description = model.Description, VehicleId = model.VehicleId, }; Add(add); Commit(); return(add); } catch (Exception) { throw; } }
public ActionResult AddCarWash(CarWashModel carWashModel) { try { if (Session["User"] == null) { return(RedirectToAction("Login", "Account")); } var vehicle = _vehicleRepository.GetVehicleByVehiclePlate(carWashModel.VehiclePlate); if (vehicle != null) { var user = (UserModel)Session["User"]; var model = new CarWashModel { VehiclePlate = carWashModel.VehiclePlate, CreatedById = user.UserId, CreatedDate = DateTime.Now, Date = DateTime.Now, Description = carWashModel.Description, IsDeleted = false, Total = carWashModel.Total, VehicleId = vehicle.VehicleId, }; var add = _carWashRepository.AddNewCarWashByCarWashModel(model); if (add != null) { return(RedirectToAction("CarWashList", "CarWash")); } } return(View()); } catch (Exception) { throw; } }