public List <PublicModel.ClientPub> GetClients() { using (var context = new CarRentContext()) { return(context.Clients.Select(x => ClientMapper.ToPublicModel(x)).ToList()); } }
public List <CarPub> GetCars(string nameFilter = null, string brandFilter = null, string colourFilter = null) { using (var context = new CarRentContext()) { var s = context.Cars.Where(x => (string.IsNullOrEmpty(nameFilter) || x.Name == nameFilter) && (string.IsNullOrEmpty(brandFilter) || x.Brand == brandFilter) && (string.IsNullOrEmpty(colourFilter) || x.Colour == colourFilter)).ToList().Select(x => CarMapper.ToPublicModel(x)).ToList(); return(s); } }
public string CreateRentDispositon(CarRentDisposition dispositionToCreate) { using (var context = new CarRentContext()) { int clientId; var existingClient = context.Clients.FirstOrDefault(x => x.DriverLicense == dispositionToCreate.Client.DriverLicense); if (existingClient == null) { var clientToCreate = new Client() { FirstName = dispositionToCreate.Client.FirstName, LastName = dispositionToCreate.Client.LastName, DriverLicense = dispositionToCreate.Client.DriverLicense }; context.Clients.Add(clientToCreate); context.SaveChanges(); clientId = clientToCreate.Id; } else { clientId = existingClient.Id; } int carId; var existingCar = context.Cars.FirstOrDefault(x => x.Brand == dispositionToCreate.Car.Brand && x.Name == dispositionToCreate.Car.CarName && x.Colour == dispositionToCreate.Car.Colour && x.Price == dispositionToCreate.Car.Price); if (existingCar == null) { carId = 1; } else { carId = existingCar.Id; } var rentDisposition = new RentDisposition() { ClientId = clientId, CarId = carId, CreatedOn = DateTime.Now }; context.RentDispostions.Add(rentDisposition); context.SaveChanges(); } return("Success"); }
private bool IsUnique(string arg) { CarRentContext context = new CarRentContext(); var result = context.Colors.Where(p => p.ColorName.ToLower() == arg.ToLower()).SingleOrDefault(); if (result == null) { return(true); } else { return(false); } }
public string CreateCar(CarPub carToCreate) { using (var context = new CarRentContext()) { context.Cars.Add(new Model.Car() { Brand = carToCreate.Brand, Colour = carToCreate.Colour, Name = carToCreate.CarName, Price = carToCreate.Price }); context.SaveChanges(); } return("Success"); }
public CarRequestsController(CarRentContext context) { _context = context; }
public MessageService(CarRentContext context, IMapper mapper) : base(context, mapper) { }
public static void Init(CarRentContext context) { context.Database.EnsureCreated(); }
public UsersController(CarRentContext context) { _context = context; }
public CarController(CarRentContext context) { db = context; }
public RepairController(CarRentContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public RentService(CarRentContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public PaymentService(CarRentContext context) { _context = context; }
public CarsRepository(CarRentContext carRentContext) { this.carRentContext = carRentContext; }
public FuelService(CarRentContext context, IMapper mapper) : base(context, mapper) { }
public ListAvailableCarsController(CarRentContext context) { _context = context; }
public BaseCRUDService(CarRentContext context, IMapper mapper) : base(context, mapper) { }
public PaymentController(CarRentContext context, IMapper mapper, IPaymentService paymentService) { _context = context; _mapper = mapper; _paymentService = paymentService; }
public CarRepository(CarRentContext context) : base(context) { }
public CustomerRepository(CarRentContext carRentContext) { this.carRentContext = carRentContext; }
public RepairService(CarRentContext context) { _context = context; }
public UnitOfWork() { _db = new CarRentContext(); }
public CarRepository(CarRentContext context) { _db = context ?? throw new ArgumentNullException(nameof(context)); }
public VehicleModelService(CarRentContext context, IMapper mapper) : base(context, mapper) { }
public ReviewService(CarRentContext context, IMapper mapper) : base(context, mapper) { }
public FavoritesService(CarRentContext context, IMapper mapper) : base(context, mapper) { }