public IActionResult Create(Int32?ID, ServiceTypes serviceType, string chosenDateTime) { if (ID == null) { return(NotFound()); } try { CultureInfo provider = CultureInfo.InvariantCulture; var chosenDate = DateTime.ParseExact(chosenDateTime, "yyyyMMddHHmmss", provider); _inProgressReservation = new Reservation(); _inProgressReservation.ProvidedService = new CarServices(); _inProgressReservation.UserID = Int32.Parse(_userManager.GetUserId(User)); _inProgressReservation.ReservationTime = chosenDate; _inProgressReservation.Workshop = _service.GetWorkShopByID((int)ID); switch (serviceType) { case ServiceTypes.TireReplacement: _inProgressReservation.ProvidedService.TireReplacement = true; break; case ServiceTypes.AirConCharging: _inProgressReservation.ProvidedService.AirConCharging = true; break; case ServiceTypes.PunctureRepair: _inProgressReservation.ProvidedService.PunctureRepair = true; break; case ServiceTypes.SuspensionAdjustment: _inProgressReservation.ProvidedService.SuspensionAdjustment = true; break; default: break; } ViewBag.ChosenShop = _inProgressReservation.Workshop.Name; ViewBag.ServiceType = serviceType; ViewBag.ChosenDate = _inProgressReservation.ReservationTime; HttpContext.Session.SetString(_service.SShopID, ID.ToString()); HttpContext.Session.SetString(_service.SServiceType, serviceType.ToString()); HttpContext.Session.SetString(_service.STime, chosenDate.ToString("yyyMMddHHmmss")); return(View(_inProgressReservation)); } catch (InvalidOperationException) { return(NotFound()); } }
public IActionResult Details(Int32 ID) { try { var workshop = _service.GetWorkShopByID(ID); return(View(workshop)); } catch (InvalidOperationException) { return(NotFound()); } }