public bool CarExists(int carId) { using (var db = new Lead2OrderGenerateDbEntities()) { return(db.l2g_tbl_Car.Any(x => x.CarId == carId)); } }
public bool CheckMileageExists(int mileageId) { using (var db = new Lead2OrderGenerateDbEntities()) { return(db.l2g_tbl_Mileage.Any(x => x.MileageId == mileageId)); } }
public static QuoteVM QuoteToBusinessEntity(l2g_tbl_Quote quote) { var quoteVM = new QuoteVM() { QuoteId = quote.QuoteId, UserId = quote.UserId, CarId = quote.CarId, Price = quote.Price, MileageId = quote.MileageId, MonthId = quote.MonthId }; using (var db = new Lead2OrderGenerateDbEntities()) { var user = db.l2g_tbl_UserDetails.Find(quote.UserId); quoteVM.Firstname = user.Firstname; quoteVM.Lastname = user.Lastname; var car = db.l2g_tbl_Car.Find(quote.CarId); //quoteVM.Carname = car.CarName; quoteVM.Model = car.Model; quoteVM.Kilometer = db.l2g_tbl_Mileage.Find(quote.MileageId).Kilometer; quoteVM.Months = db.l2g_tbl_PaybackTime.Find(quote.MonthId).Months; } return(quoteVM); }
public bool CheckMonthsExists(int id) { using (var db = new Lead2OrderGenerateDbEntities()) { return(db.l2g_tbl_PaybackTime.Any(x => x.MonthId == id)); } }
public List <MileageVM> GetMileages() { using (var db = new Lead2OrderGenerateDbEntities()) { List <l2g_tbl_Mileage> mileages = db.l2g_tbl_Mileage.ToList(); if (mileages.Count > 0) { List <MileageVM> mileageVMs = new List <MileageVM>(); foreach (var mileage in mileages) { mileageVMs.Add(MappingConfig.MileageToBusinessEntity(mileage)); } return(mileageVMs); } } return(new List <MileageVM>()); }
public List <GearboxVM> GetGearboxTypes() { using (var db = new Lead2OrderGenerateDbEntities()) { List <l2g_tbl_Gearbox> gearboxTypes = db.l2g_tbl_Gearbox.ToList(); if (gearboxTypes.Count > 0) { List <GearboxVM> gearboxVMs = new List <GearboxVM>(); foreach (var gearBoxType in gearboxTypes) { gearboxVMs.Add(MappingConfig.GearboxToBusinessEntity(gearBoxType)); } return(gearboxVMs); } return(new List <GearboxVM>()); } }
public List <FuelVM> GetFuelTypes() { using (var db = new Lead2OrderGenerateDbEntities()) { List <l2g_tbl_Fuel> fuelTypes = db.l2g_tbl_Fuel.ToList(); if (fuelTypes.Count > 0) { List <FuelVM> fuelVMs = new List <FuelVM>(); foreach (var fuelType in fuelTypes) { fuelVMs.Add(MappingConfig.FuelToBusinessEntity(fuelType)); } return(fuelVMs); } return(new List <FuelVM>()); } }
public List <BrandVM> GetBrands() { using (var db = new Lead2OrderGenerateDbEntities()) { List <l2g_tbl_Brand> brands = db.l2g_tbl_Brand.ToList(); if (brands.Count > 0) { List <BrandVM> brandVMs = new List <BrandVM>(); foreach (var brand in brands) { brandVMs.Add(MappingConfig.BrandToBusinessEntity(brand)); } return(brandVMs); } return(new List <BrandVM>()); } }
public List <CarVM> GetCars() { using (var db = new Lead2OrderGenerateDbEntities()) { List <l2g_tbl_Car> cars = db.l2g_tbl_Car.ToList(); if (cars.Count > 0) { List <CarVM> carVMs = new List <CarVM>(); foreach (var car in cars) { carVMs.Add(MappingConfig.CarToBusinessEntity(car)); } return(carVMs); } return(new List <CarVM>()); } }
public List <PaybackTimeVM> GetPaybackTimes() { using (var db = new Lead2OrderGenerateDbEntities()) { List <l2g_tbl_PaybackTime> paybackTimes = db.l2g_tbl_PaybackTime.ToList(); if (paybackTimes.Count > 0) { List <PaybackTimeVM> paybackTimeVMs = new List <PaybackTimeVM>(); foreach (var paybackTime in paybackTimes) { paybackTimeVMs.Add(MappingConfig.paybackTimeToBusinessEntity(paybackTime)); } return(paybackTimeVMs); } } return(new List <PaybackTimeVM>()); }
public static UserEmploymentDetailsVM UserEmploymentDetailsToBusinessEntity(l2g_tbl_UserEmployeementDetails user) { var userVM = new UserEmploymentDetailsVM() { UserId = user.UserId, Company = user.Company, Salary = user.Salary, CreditScore = user.CreditScore, EmployeeStatusId = user.EmployeeStatusId ?? 4, ContractId = user.ContractId ?? 2, }; using (var db = new Lead2OrderGenerateDbEntities()) { userVM.ContractType = db.l2g_tbl_Contract.Find(userVM.ContractId).ContractType; userVM.EmployeeStatusType = db.l2g_tbl_EmployeeStatus.Find(userVM.EmployeeStatusId).EmployeeStatusType; } return(userVM); }
public bool AddQuote(GetQuote quote, int userId) { l2g_tbl_Quote quoteEntity = MappingConfig.GetQuoteToDataEntity(quote); quoteEntity.UserId = userId; quoteEntity.CreatedDate = DateTime.Now; using (var db = new Lead2OrderGenerateDbEntities()) { try { db.l2g_tbl_Quote.Add(quoteEntity); db.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
public static CarVM CarToBusinessEntity(l2g_tbl_Car car) { var carVM = new CarVM() { CarId = car.CarId, //Carname = car.CarName, Model = car.Model, Color = car.Color, Price = (float)car.Price, CO2Emission = (float)car.CO2Emission }; using (var db = new Lead2OrderGenerateDbEntities()) { carVM.Brand = MappingConfig.BrandToBusinessEntity(db.l2g_tbl_Brand.Find(car.BrandId)); carVM.Fuel = MappingConfig.FuelToBusinessEntity(db.l2g_tbl_Fuel.Find(car.FuelId)); carVM.Gearbox = MappingConfig.GearboxToBusinessEntity(db.l2g_tbl_Gearbox.Find(car.GearboxId)); } return(carVM); }