public ActionResult Create([Bind(Include = "id,High,StartDate,EndDate")] Season season) { if (ModelState.IsValid) { db.Seasons.Add(season); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(season)); }
public ActionResult Create([Bind(Include = "Id_kategoria,Nazwa")] kategorie kategorie) { if (ModelState.IsValid) { db.kategorie.Add(kategorie); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(kategorie)); }
public ActionResult Create([Bind(Include = "Id_model,Nazwa")] modele modele) { if (ModelState.IsValid) { db.modele.Add(modele); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(modele)); }
public ActionResult Create([Bind(Include = "Id_marka,Nazwa")] marki marki) { if (ModelState.IsValid) { db.marki.Add(marki); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(marki)); }
public ActionResult Create([Bind(Include = "id,CustID,DateOut,DateIn,Class,Notes")] Booking booking) { if (ModelState.IsValid) { db.Bookings.Add(booking); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(booking)); }
public ActionResult Create([Bind(Include = "id,Class,FreeKMs,HighSeasonDay,LowSeasonDay,HighSeasonKM,LowSeasonKM,Example,ImageSource")] Price price) { if (ModelState.IsValid) { db.Prices.Add(price); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(price)); }
public ActionResult Create([Bind(Include = "Id_uzytkownik,Imie,Nazwisko,Adres_zamieszkania,Data_urodzenia,Login,Haslo,Rola,Nr_prawa_jazdy,PESEL")] uzytkownicy uzytkownicy) { if (ModelState.IsValid) { db.uzytkownicy.Add(uzytkownicy); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Rola = new SelectList(db.Role, "Id_rola", "Nazwa", uzytkownicy.Rola); return(View(uzytkownicy)); }
public ActionResult Create([Bind(Include = "id,FirstName,LastName,DOB,IDnum,Email,Notes")] Customer customer) { if (ModelState.IsValid) { db.Customers.Add(customer); customer.MemberSince = DateTime.Today; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer)); }
public ActionResult Create([Bind(Include = "Id_wypozyczenia,Id_uzytkownika,Id_samochodu,Data_wypozyczenia,Data_zwrotu,Cena")] wypozyczenia wypozyczenia) { if (ModelState.IsValid) { db.wypozyczenia.Add(wypozyczenia); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Id_samochodu = new SelectList(db.samochody, "Id_samochod", "Id_samochod", wypozyczenia.Id_samochodu); ViewBag.Id_uzytkownika = new SelectList(db.uzytkownicy, "Id_uzytkownik", "Id_uzytkownik", wypozyczenia.Id_uzytkownika); return(View(wypozyczenia)); }
public ActionResult Create([Bind(Include = "Id_samochod,Rocznik,Silnik,Id_marka,Id_model,Data_rejestracji,Cena,Id_kategoria")] samochody samochody) { if (ModelState.IsValid) { db.samochody.Add(samochody); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Id_kategoria = new SelectList(db.kategorie, "Id_kategoria", "Nazwa", samochody.Id_kategoria); ViewBag.Id_marka = new SelectList(db.marki, "Id_marka", "Nazwa", samochody.Id_marka); ViewBag.Id_model = new SelectList(db.modele, "Id_model", "Nazwa", samochody.Id_model); return(View(samochody)); }
public ActionResult Create([Bind(Include = "id,Class,CarType,Make,Model,Color,Doors,KMs,LicensePlate,DateOnRoad,NextServiceDate,NextServiceKMS,StatusInService,StatusRented,CustID,Notes")] Car car) { if (ModelState.IsValid) { car.StatusInService = true; car.StatusRented = false; db.Cars.Add(car); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(car)); }
public IHttpActionResult NewCustomer(Customer customer) { if (!ModelState.IsValid) { return(BadRequest("Invalid data.")); } db.Customers.Add(new Customer() { FirstName = customer.FirstName, LastName = customer.LastName, DOB = customer.DOB, MemberSince = DateTime.Today, Email = customer.Email, IDnum = customer.IDnum, Notes = "Customer added through WebAPI" });; db.SaveChanges(); return(Ok()); }
public ActionResult Create([Bind(Include = "id,CustID,CarID,DateOut,DateIn,Status,Notes")] Rental rental) { if (ModelState.IsValid) { db.Rentals.Add(rental); rental.Status = true; rental.DateOut = DateTime.Now; Car car = db.Cars.Find(rental.CarID); rental.MileageOut = car.KMs; car.CustID = rental.CustID; car.StatusRented = true; Price price = (from pri in db.Prices where pri.Class == car.Class select pri).FirstOrDefault(); //the following line will return the wrong info if car was returned different year to when it was taken int daysExpected = (rental.DateIn.Value.DayOfYear - rental.DateOut.Value.DayOfYear); if (daysExpected == 0) { daysExpected = 1; } int?freeKms = daysExpected * price.FreeKMs; //the following code will only get high season if the whole rental was within high season. this must be fixed //var season = (from sea in db.Seasons // where rental.DateOut >= sea.StartDate // where rental.DateIn <= sea.EndDate // select sea.High).FirstOrDefault(); bool season = true; if (season == true) { rental.PriceDay = price.HighSeasonDay; rental.PriceKM = price.HighSeasonKM; } else { rental.PriceDay = price.LowSeasonDay; rental.PriceKM = price.LowSeasonKM; } rental.FreeKMs = freeKms / daysExpected; rental.SeasonHigh = season; rental.Days = daysExpected; db.SaveChanges(); //need customer name for sending personalized email: Customer customer = db.Customers.Find(car.CustID); string seasonString = season == true ? "high" : "low"; //first parameter should be customer.email, but since no domain set up yet, can't use other email addresses SendEmail("*****@*****.**", "Car Rented", $"Hi {customer.FirstName} {customer.LastName} \n \n" + $"Thank you for renting a car from The King Car! \n \n" + $"Details of your rental: \n" + $"{car.Color} {car.Make} {car.Model} \n" + $"License Plate Number: {car.LicensePlate} \n" + $"Class: ({car.Class}) {car.CarType} \n \n" + $"You have the car until: {rental.DateIn.Value.ToShortDateString()} \n" + $"The price per day in {seasonString} season is {rental.PriceDay.Value.ToString("F")}₪ \n" + $"You have {rental.FreeKMs} per day free KMs. Total free KMs: {freeKms} \n" + $"If you go over that total you will be charged the {seasonString} season price of {rental.PriceKM.Value.ToString("F")}₪ per extra KM \n \n" + "If you have any issues, please conact us \n \n" + "Yours Sincerely \n" + "The King Car"); return(RedirectToAction("Details", new { id = rental.id })); } return(View(rental)); }