public ActionResult PersonDetails() { ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId()); var osoba = osobaRepository.GetOsobaByHash(user.UserHash); return(View(osoba)); }
// GET: Rent public ActionResult RentCar() { ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId()); var osoba = osobaRepository.GetOsobaByHash(user.UserHash); if (osoba.Adres == null || osoba.DataUrodzenia == null || osoba.KodPocztowy == null || osoba.Kraj == null || osoba.NrTelefonu == null || osoba.Miasto == null) { return(View("AddYourPersonalData")); } var wypTemp = wypozyczenieTempRepository.FindWypozyczenieTempForOsobaId(osoba.OsobaId); var lengthOfRent = wypTemp.FirstOrDefault().DataZwrotu.Date.Day - wypTemp.FirstOrDefault().DataWypozyczenia.Date.Day; List <SelectListItem> wydarzenieList = new SelectList(wydarzenieRepository.FindAllWydarzenie(), "WydarzenieId", "NazwaWydarzenia").ToList(); ViewData["wydarzenieList"] = wydarzenieList; RentCarViewModel rentCar = new RentCarViewModel(); rentCar.CarInCartList = wypTemp; foreach (var item in rentCar.CarInCartList) { if (item.Samochod.Cennik.Count() > 0) { if (lengthOfRent < 7) { if (item.Samochod.Cennik.Where(c => c.Opis == "dzien").Count() > 0) { item.PricePerDay = (item.Samochod.Cennik.Where(c => c.Opis == "dzien").SingleOrDefault().Cena); rentCar.TotalPrice += item.PricePerDay * lengthOfRent; } } else if (lengthOfRent >= 7 && lengthOfRent < 30) { if (item.Samochod.Cennik.Where(c => c.Opis == "tydzien").Count() > 0) { item.PricePerDay = (item.Samochod.Cennik.Where(c => c.Opis == "tydzien").SingleOrDefault().Cena); rentCar.TotalPrice += item.PricePerDay * lengthOfRent; } } else if (lengthOfRent >= 30) { if (item.Samochod.Cennik.Where(c => c.Opis == "miesiac").Count() > 0) { item.PricePerDay = (item.Samochod.Cennik.Where(c => c.Opis == "miesiac").SingleOrDefault().Cena); rentCar.TotalPrice += item.PricePerDay * lengthOfRent; } } } } rentCar.DataWypozyczenia = wypTemp.FirstOrDefault().DataWypozyczenia; rentCar.DataZwrotu = wypTemp.FirstOrDefault().DataZwrotu; rentCar.OsobaId = osoba.OsobaId; return(View(rentCar)); }
public ActionResult Create(Guid UserHash) { List <SelectListItem> stanowiskoList = new SelectList(PracownikSelectList.StanowikoList, "Key", "Value").ToList(); ViewData["stanowiskoList"] = stanowiskoList; var osoba = osobaRepository.GetOsobaByHash(UserHash); Pracownik pracownik = new Pracownik(); pracownik.OsobaId = osoba.OsobaId; return(View(pracownik)); }
public ActionResult SearchCar() { ApplicationUser user = System.Web.HttpContext.Current.GetOwinContext().GetUserManager <ApplicationUserManager>().FindById(System.Web.HttpContext.Current.User.Identity.GetUserId()); var osoba = osobaRepository.GetOsobaByHash(user.UserHash); SearchViewModel searchViewModel = new SearchViewModel(); searchViewModel.wypTemp = wypozyczenieTempRepository.FindWypozyczenieTempForOsobaId(osoba.OsobaId); if (searchViewModel.wypTemp.Count() > 0) { searchViewModel.dataWyp = searchViewModel.wypTemp.FirstOrDefault().DataWypozyczenia; searchViewModel.dataZwr = searchViewModel.wypTemp.FirstOrDefault().DataZwrotu; } else { searchViewModel.dataWyp = DateTime.Now.AddDays(1); searchViewModel.dataZwr = DateTime.Now.AddDays(8); } ViewBag.OsobaId = osobaRepository.GetOsobaByHash(user.UserHash).OsobaId; return(View(searchViewModel)); }