public ActionResult News() { using (RatesDBContext ctx = new RatesDBContext()) { return(View(ctx.News.ToList())); } }
public IEnumerable <SelectListItem> GetLocations() { List <SelectListItem> sl = new List <SelectListItem>(); using (RatesDBContext ctx = new RatesDBContext()) { List <Location> locs = ctx.Locations.Where(s => s.IsAvailable).ToList(); foreach (Location l in locs) { sl.Add(new SelectListItem { Text = l.Name, Value = l.LocationId.ToString() }); } } //List<SelectListItem> sl = new List<SelectListItem>(); //sl.Add(new SelectListItem { Selected = false, Text = "Gdansk", Value = "12" }); //sl.Add(new SelectListItem { Selected = true, Text = "Riga", Value = "3" }); //sl.Add(new SelectListItem { Selected = false, Text = "Kaunas", Value = "2" }); //sl.Add(new SelectListItem { Selected = false, Text = "Krakow", Value = "11" }); //sl.Add(new SelectListItem { Selected = false, Text = "Vilnius", Value = "1" }); //sl.Add(new SelectListItem { Selected = false, Text = "Warsaw (Chopin)", Value = "4" }); //sl.Add(new SelectListItem { Selected = false, Text = "Warsaw (Modlin)", Value = "9" }); //sl.Add(new SelectListItem { Selected = false, Text = "London", Value = "5" }); //sl.Add(new SelectListItem { Selected = false, Text = "Fiumicino", Value = "6" }); //sl.Add(new SelectListItem { Selected = false, Text = "Rome", Value = "7" }); //sl.Add(new SelectListItem { Selected = false, Text = "Bologna", Value = "8" }); //sl.Add(new SelectListItem { Selected = false, Text = "Prague", Value = "10" }); return(new SelectList(sl, "Value", "Text")); }
// GET: Cars public ActionResult Index() { using (RatesDBContext ctx = new RatesDBContext()) { return(View(ctx.Cars.Where(c => c.IsAssigned).OrderBy(o => o.Category).ToList())); } }
public JsonResult GetIntervals(int?locationId) { IntervalDates[] intDates = new IntervalDates[7]; if (locationId > 0) { using (RatesDBContext ctx = new RatesDBContext()) { for (int i = 1; i <= 6; i++) { Update updt = ctx.Updates.Where(w => w.LocationId == locationId && w.IntervalNum == i).OrderByDescending(o => o.UpdateTime).FirstOrDefault(); if (updt != null) { intDates[i] = new IntervalDates { PuDate = updt.PickupTime, DoDate = updt.DropoffTime } } ; } } } return(new JsonResult() { Data = intDates, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }
public bool AddRate(Rate rate) { Console.WriteLine("\r\n{0} - Adding Rate", DateTime.Now); using(RatesDBContext context = new RatesDBContext()) { context.Rates.Add(new Rate() { Value = rate.Value, RateDescription = rate.RateDescription }); context.SaveChanges(); Console.WriteLine("{0} Rate Value : {1}",rate.RateDescription, rate.Value.ToString()); return true; } }
public Dictionary <string, Dictionary <string, JOffer> > GetCarTrawlerRatesSingle(SearchFilters searchFilters, out SiteBase site) { Dictionary <int, Location> locations; using (RatesDBContext ctx = new RatesDBContext()) { locations = ctx.Locations.ToDictionary(loc => loc.LocationId); } Trawler s = new Trawler(locations[searchFilters.Location].CtrStr); DateTime sDate = searchFilters.PuDate; //.AddHours(searchFilters.PuTime.Hours).AddMinutes(searchFilters.PuTime.Minutes); DateTime eDate = searchFilters.DoDate; //.AddHours(searchFilters.DoTime.Hours).AddMinutes(searchFilters.DoTime.Minutes); s.InitDate(sDate); int numOfIterations = (eDate - sDate).Days; List <string> links = s.GetGeneratedLinksByDate(sDate, eDate); site = s; List <JOffer> minOffers = new List <JOffer>(); Dictionary <string, Dictionary <string, JOffer> > offerMap = new Dictionary <string, Dictionary <string, JOffer> >(); for (int i = 0; i < links.Count; i++) { offerMap.Add(links[i], new Dictionary <string, JOffer>()); } List <Thread> threads = new List <Thread>(); //--- Start all threads for (int index = 0; index < links.Count; index++) { JSourceReader reader = new JSourceReader(); offerMap[links.ElementAt(index)] = reader.GetMap(reader.GetNorwRates(links.ElementAt(index))); } return(offerMap); }
public Dictionary <string, Dictionary <string, JOffer> > GetScannerRates(SearchFilters searchFilters, out SiteBase site) { Dictionary <int, Location> locations; using (RatesDBContext ctx = new RatesDBContext()) { locations = ctx.Locations.ToDictionary(loc => loc.LocationId); } Trawler s = new Trawler(locations[searchFilters.Location].SnrStr); DateTime sDate = searchFilters.PuDate.AddHours(searchFilters.PuTime.Hours).AddMinutes(searchFilters.PuTime.Minutes); DateTime eDate = searchFilters.DoDate.AddHours(searchFilters.DoTime.Hours).AddMinutes(searchFilters.DoTime.Minutes); s.InitDate(sDate); int numOfIterations = (eDate - sDate).Days; List <string> links = s.GetGeneratedLinksByDate(sDate, eDate); List <JOffer> minOffers = new List <JOffer>(); Dictionary <string, Dictionary <string, JOffer> > offerMap = new Dictionary <string, Dictionary <string, JOffer> >(); for (int i = 0; i < links.Count; i++) { offerMap.Add(links[i], new Dictionary <string, JOffer>()); } Func <object, int> action = (object obj) => { int i = (int)obj; JSourceReader reader = new JSourceReader(); offerMap[links.ElementAt(i)] = reader.GetMap(reader.GetNorwRates(links.ElementAt(i))); return(0); }; RunThreads(action, links.Count); s.SetTitle("scanner"); site = s; return(offerMap); }
public bool AddRole(Role role) { Console.WriteLine("\r\n{0} - Adding Role", DateTime.Now); using(RatesDBContext context = new RatesDBContext()) { Rate rate = context.Rates.Where(r => r.RateID == role.RateID).FirstOrDefault<Rate>(); if (rate != null) { context.Roles.Add(new Role() { RoleName = role.RoleName, Rate = rate }); context.SaveChanges(); Console.WriteLine("Role : {0} with rate : {1}",role.RoleName, rate.Value.ToString()); return true; } else { return false; } } }
public bool AddEmployee(Employee emp) { Console.WriteLine("\r\n{0} - Adding Employee", DateTime.Now); using(RatesDBContext context = new RatesDBContext()) { Role role = context.Roles.Where(r => r.RoleID == emp.RoleID).FirstOrDefault<Role>(); if(role != null) { context.Employees.Add(new Employee() { EmployeeName = emp.EmployeeName, EmployeeSurname = emp.EmployeeSurname, EmployeeNumber = emp.EmployeeNumber, Role = role }); context.SaveChanges(); Console.WriteLine("Employee Name : {0} To : {1}", emp.EmployeeName,role.RoleName); return true; } else { return false; } } }
public Dictionary <string, Dictionary <string, JOffer> > GetRentalRates(SearchFilters searchFilters, out SiteBase site) { Log.Instance.Warn("---Begin: GetRentalRates"); DateTime sDate = searchFilters.PuDate; DateTime eDate = searchFilters.DoDate; Dictionary <int, Location> locations; using (RatesDBContext ctx = new RatesDBContext()) { locations = ctx.Locations.ToDictionary(loc => loc.LocationId); } Rental s = new Rental(locations[searchFilters.Location].JigStr); s.SetTime(searchFilters.PuTime.Hours, searchFilters.PuTime.Minutes, searchFilters.DoTime.Hours, searchFilters.DoTime.Minutes); s.InitDate(sDate); site = s; int numOfIterations = (eDate - sDate).Days; List <string> links = s.GetGeneratedLinksByDate(sDate, eDate); List <JOffer> minOffers = new List <JOffer>(); Dictionary <string, Dictionary <string, JOffer> > offerMap = new Dictionary <string, Dictionary <string, JOffer> >(); for (int i = 0; i < links.Count; i++) { offerMap.Add(links[i], new Dictionary <string, JOffer>()); } Func <object, int> action = (object obj) => { int i = (int)obj; JSourceReader reader = new JSourceReader(); offerMap[links.ElementAt(i)] = reader.GetMap(reader.ExtractOffers(reader.GetResultGroup(links.ElementAt(i)))); return(0); }; RunThreads(action, links.Count); Log.Instance.Warn("---END: GetRentalRates"); return(offerMap); }
public ICollection<Employee> Employees() { Console.WriteLine("\r\n{0} - Getting Employees", DateTime.Now); List<Employee> Employees = new List<Employee>(); using(RatesDBContext context = new RatesDBContext()) { foreach (Employee employee in context.Employees) { Employee e = new Employee(); e.EmployeeID = employee.EmployeeID; e.EmployeeName = employee.EmployeeName; e.EmployeeNumber = employee.EmployeeNumber; e.EmployeeSurname = employee.EmployeeSurname; e.RoleID = employee.RoleID; Employees.Add(e); Console.WriteLine("Employee : {0} {1}", e.EmployeeName, e.EmployeeSurname); } return Employees; } }
public void AddCar(SupplierNew s) { using (RatesDBContext ctx = new RatesDBContext()) { Cars c = ctx.Cars.FirstOrDefault(o => o.CarName.Contains(s.CarName)); if (c == null) { ctx.Cars.Add(new Cars { CarName = s.CarName, Category = s.Category.Contains("skip") ? s.Category.Substring(4) : s.Category, Seats = s.Seats, Transmission = s.Transmission, SupplierName = s.SupplierName, SupplierType = s.SupplierType, IsAssigned = true }); ctx.SaveChanges(); } } }
public ICollection<Rate> Rates() { Console.WriteLine("\r\n{0} - Getting Rates", DateTime.Now); ICollection<Rate> Rate = new List<Rate>(); using (RatesDBContext context = new RatesDBContext()) { foreach (Rate rate in context.Rates) { Rate r = new Rate(); r.RateID = rate.RateID; r.RateDescription = rate.RateDescription; r.Value = rate.Value; Rate.Add(r); Console.WriteLine("Rate Value : {0}", r.Value.ToString()); } return Rate; } }
public ICollection<Role> Roles() { Console.WriteLine("\r\n{0} - Getting Roles", DateTime.Now); ICollection<Role> Roles = new List<Role>(); using (RatesDBContext context = new RatesDBContext()) { foreach (Role role in context.Roles) { Role r = new Role(); r.RoleName = role.RoleName; r.RateID = role.RateID; r.RoleID = role.RoleID; Roles.Add(r); Console.WriteLine("Role Name : {0}", r.RoleName); } } return Roles; }
public bool UpdateEmployee(Employee emp) { Console.WriteLine("\r\n{0} - Updating Employee", DateTime.Now); using (RatesDBContext context = new RatesDBContext()) { Employee employee = context.Employees.Where(e => e.EmployeeID == emp.EmployeeID).FirstOrDefault<Employee>(); if (employee != null) { employee.EmployeeName = emp.EmployeeName; employee.EmployeeNumber = emp.EmployeeNumber; employee.EmployeeSurname = emp.EmployeeSurname; employee.RoleID = emp.RoleID; context.SaveChanges(); Console.WriteLine("Employee Name : {0}",emp.EmployeeName); return true; } else { return false; } } }
public bool UpdateRate(Rate rate) { Console.WriteLine("\r\n{0} - Updating Rate", DateTime.Now); using (RatesDBContext context = new RatesDBContext()) { Rate rateRecord = context.Rates.Where(r => r.RateID == rate.RateID).FirstOrDefault<Rate>(); if (rateRecord != null) { rateRecord.RateDescription = rate.RateDescription; rateRecord.Value = rate.Value; context.SaveChanges(); Console.WriteLine("{0} Rate Value : {1}", rate.RateDescription, rate.Value.ToString()); return true; } else { return false; } } }
public bool UpdateRole(Role role) { Console.WriteLine("\r\n{0} - Updating Role", DateTime.Now); using (RatesDBContext context = new RatesDBContext()) { Role roleRecord = context.Roles.Where(r => r.RoleID == role.RoleID).FirstOrDefault<Role>(); if (roleRecord != null) { roleRecord.RoleName = role.RoleName; roleRecord.RateID = role.RateID; context.SaveChanges(); Console.WriteLine("Role : {0}", role.RoleName); return true; } else { return false; } } }