public async Task <IActionResult> Create([Bind("Id,Services,Prices")] Types types) { if (ModelState.IsValid) { var userId = HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier); var type = new Types(); { type.Id = types.Id; } _context.Add(types); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(TypesController.Index), "Types")); } return(View(types)); }
public async Task <IActionResult> Create(Car carModel) { if (ModelState.IsValid) { var userId = HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier); var car = new Car(); { car.Id = carModel.Id; car.CarColor = carModel.CarColor; car.CarNo = carModel.CarNo; car.CarType = carModel.CarType; car.UserId = userId; } _context.Add(car); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(ReservationsController.Create), "Reservations", new { carid = car.Id })); } return(View(carModel)); }
public async Task <IActionResult> Create(Location locationModel) { if (ModelState.IsValid) { var userId = HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier); var location = new Location(); { location.Id = locationModel.Id; location.DateTime = locationModel.DateTime; location.Day = locationModel.Day; location.Latitude = locationModel.Latitude; location.Longitude = locationModel.Longitude; location.UserId = userId; } _context.Add(location); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(LocationsController.Index), "Locations")); } return(View(locationModel)); }
public async Task <IActionResult> Create(Reservation reservationModel) { if (ModelState.IsValid) { var userId = HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier); var car = _context.Car.Where(x => x.Id == reservationModel.CarId).FirstOrDefault(); var type = _context.Types.Where(x => x.Id == reservationModel.TypesId).FirstOrDefault(); double Prices = type.Prices; string CarType = car.CarType; int TypeId = type.Id; double Amount = reservationModel.Amount; if (CarType == "Sedan") { if (TypeId == 22) { Amount += Prices; if (reservationModel.Vacuum) { Amount += Prices + 2; } else if (reservationModel.Polish) { Amount += Prices + 5; } else if (reservationModel.Amortires) { Amount += Prices + 2; } else if (reservationModel.Freshner) { Amount += Prices + 2; } } else if (TypeId == 23) { Amount += Prices; if (reservationModel.Leatherconditioner) { Amount += Prices + 4; } else if (reservationModel.Polish) { Amount += Prices + 5; } else if (reservationModel.Enginewash) { Amount += Prices + 5; } else if (reservationModel.Freshner) { Amount += Prices + 2; } } else { Amount += Prices; if (reservationModel.Leatherconditioner) { Amount += Prices + 4; } else if (reservationModel.Polish) { Amount += Prices + 5; } else if (reservationModel.Freshner) { Amount += Prices + 2; } } } else if (CarType == "MPV") { if (TypeId == 22) { Amount += Prices + 2; if (reservationModel.Vacuum) { Amount += Prices + 2; } else if (reservationModel.Polish) { Amount += Prices + 5; } else if (reservationModel.Amortires) { Amount += Prices + 3; } else if (reservationModel.Freshner) { Amount += Prices + 2; } } else if (TypeId == 23) { Amount += Prices + 3; if (reservationModel.Leatherconditioner) { Amount += Prices + 4; } else if (reservationModel.Polish) { Amount += Prices + 5; } else if (reservationModel.Enginewash) { Amount += Prices + 5; } else if (reservationModel.Freshner) { Amount += Prices + 2; } } else { Amount += Prices + 1; if (reservationModel.Leatherconditioner) { Amount += Prices + 4; } else if (reservationModel.Polish) { Amount += Prices + 5; } else if (reservationModel.Freshner) { Amount += Prices + 2; } } } else if (CarType == "SUV") { if (TypeId == 22) { Amount += Prices + 4; if (reservationModel.Vacuum) { Amount += Prices + 4; } else if (reservationModel.Polish) { Amount += Prices + 8; } else if (reservationModel.Amortires) { Amount += Prices + 2; } else if (reservationModel.Freshner) { Amount += Prices + 2; } } else if (TypeId == 23) { Amount += Prices + 5; if (reservationModel.Leatherconditioner) { Amount += Prices + 5; } else if (reservationModel.Polish) { Amount += Prices + 8; } else if (reservationModel.Enginewash) { Amount += Prices + 5; } else if (reservationModel.Freshner) { Amount += Prices + 2; } } else { Amount += Prices + 5; if (reservationModel.Leatherconditioner) { Amount += Prices + 5; } else if (reservationModel.Polish) { Amount += Prices + 8; } else if (reservationModel.Freshner) { Amount += Prices + 2; } } } else if (CarType == "Hatchback") { if (TypeId == 22) { Amount += Prices; if (reservationModel.Vacuum) { Amount += Prices + 2; } else if (reservationModel.Polish) { Amount += Prices + 5; } else if (reservationModel.Amortires) { Amount += Prices + 2; } else if (reservationModel.Freshner) { Amount += Prices + 2; } } else if (TypeId == 23) { Amount += Prices; if (reservationModel.Leatherconditioner) { Amount += Prices + 4; } else if (reservationModel.Polish) { Amount += Prices + 5; } else if (reservationModel.Enginewash) { Amount += Prices + 5; } else if (reservationModel.Freshner) { Amount += Prices + 2; } } else { Amount += Prices; if (reservationModel.Leatherconditioner) { Amount += Prices + 4; } else if (reservationModel.Polish) { Amount += Prices + 5; } else if (reservationModel.Freshner) { Amount += Prices + 2; } } } else if (CarType == "Convertible") { if (TypeId == 22) { Amount += Prices + 6; if (reservationModel.Vacuum) { Amount += Prices + 4; } else if (reservationModel.Polish) { Amount += Prices + 8; } else if (reservationModel.Amortires) { Amount += Prices + 2; } else if (reservationModel.Freshner) { Amount += Prices + 2; } } else if (TypeId == 23) { Amount += Prices + 5; if (reservationModel.Leatherconditioner) { Amount += Prices + 5; } else if (reservationModel.Polish) { Amount += Prices + 8; } else if (reservationModel.Enginewash) { Amount += Prices + 5; } else if (reservationModel.Freshner) { Amount += (Prices + 2); } } else { Amount += Prices + 10; if (reservationModel.Leatherconditioner) { Amount += Prices + 5; } else if (reservationModel.Polish) { Amount += Prices + 8; } else if (reservationModel.Freshner) { Amount += Prices + 2; } } } else { if (TypeId == 22) { Amount += Prices + 6; if (reservationModel.Vacuum) { Amount += Prices + 2; } else if (reservationModel.Polish) { Amount += Prices + 8; } else if (reservationModel.Amortires) { Amount += Prices + 2; } else if (reservationModel.Freshner) { Amount += Prices + 2; } } else if (TypeId == 23) { Amount += Prices + 5; if (reservationModel.Leatherconditioner) { Amount += Prices + 6; } else if (reservationModel.Polish) { Amount += Prices + 8; } else if (reservationModel.Enginewash) { Amount += Prices + 5; } else if (reservationModel.Freshner) { Amount += Prices + 2; } } else { Amount += Prices + 10; if (reservationModel.Leatherconditioner) { Amount += Prices + 6; } else if (reservationModel.Polish) { Amount += Prices + 8; } else if (reservationModel.Freshner) { Amount = Prices + 2; } } }; var reservation = new Reservation(); { reservation.Id = reservationModel.Id; reservation.Address = reservationModel.Address; reservation.Latitude = reservationModel.Latitude; reservation.Longitude = reservationModel.Longitude; reservation.Date = reservationModel.Date; reservation.Day = reservationModel.Day; reservation.Amount = Amount; reservation.Vacuum = reservationModel.Vacuum; reservation.Polish = reservationModel.Polish; reservation.Freshner = reservationModel.Freshner; reservation.Amortires = reservationModel.Amortires; reservation.Enginewash = reservationModel.Enginewash; reservation.Leatherconditioner = reservationModel.Leatherconditioner; reservation.CarId = reservationModel.CarId; reservation.TypesId = reservationModel.TypesId; reservation.Payment = reservationModel.Payment; reservation.Answer = reservationModel.Answer; reservation.Comment = reservationModel.Comment; }; _context.Add(reservation); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(ReservationsController.Confirmation), "Reservations")); } return(View(reservationModel)); }