コード例 #1
0
 public List <PublicModel.ClientPub> GetClients()
 {
     using (var context = new CarRentContext())
     {
         return(context.Clients.Select(x => ClientMapper.ToPublicModel(x)).ToList());
     }
 }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
        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");
        }
コード例 #4
0
        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);
            }
        }
コード例 #5
0
        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");
        }
コード例 #6
0
 public CarRequestsController(CarRentContext context)
 {
     _context = context;
 }
コード例 #7
0
 public MessageService(CarRentContext context, IMapper mapper) : base(context, mapper)
 {
 }
コード例 #8
0
ファイル: SetupService.cs プロジェクト: ajdintbk/CarRent
 public static void Init(CarRentContext context)
 {
     context.Database.EnsureCreated();
 }
コード例 #9
0
 public UsersController(CarRentContext context)
 {
     _context = context;
 }
コード例 #10
0
 public CarController(CarRentContext context)
 {
     db = context;
 }
コード例 #11
0
 public RepairController(CarRentContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
コード例 #12
0
 public RentService(CarRentContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
コード例 #13
0
 public PaymentService(CarRentContext context)
 {
     _context = context;
 }
コード例 #14
0
 public CarsRepository(CarRentContext carRentContext)
 {
     this.carRentContext = carRentContext;
 }
コード例 #15
0
 public FuelService(CarRentContext context, IMapper mapper) : base(context, mapper)
 {
 }
コード例 #16
0
 public ListAvailableCarsController(CarRentContext context)
 {
     _context = context;
 }
コード例 #17
0
ファイル: BaseCRUDService.cs プロジェクト: ajdintbk/CarRent
 public BaseCRUDService(CarRentContext context, IMapper mapper) : base(context, mapper)
 {
 }
コード例 #18
0
 public PaymentController(CarRentContext context, IMapper mapper, IPaymentService paymentService)
 {
     _context        = context;
     _mapper         = mapper;
     _paymentService = paymentService;
 }
コード例 #19
0
 public CarRepository(CarRentContext context)
     : base(context)
 {
 }
コード例 #20
0
 public CustomerRepository(CarRentContext carRentContext)
 {
     this.carRentContext = carRentContext;
 }
コード例 #21
0
ファイル: RepairService.cs プロジェクト: Spasibovsem/CarRent
 public RepairService(CarRentContext context)
 {
     _context = context;
 }
コード例 #22
0
 public UnitOfWork()
 {
     _db = new CarRentContext();
 }
コード例 #23
0
 public CarRepository(CarRentContext context)
 {
     _db = context ??
           throw new ArgumentNullException(nameof(context));
 }
コード例 #24
0
 public VehicleModelService(CarRentContext context, IMapper mapper) : base(context, mapper)
 {
 }
コード例 #25
0
ファイル: ReviewService.cs プロジェクト: ajdintbk/CarRent
 public ReviewService(CarRentContext context, IMapper mapper) : base(context, mapper)
 {
 }
コード例 #26
0
 public FavoritesService(CarRentContext context, IMapper mapper) : base(context, mapper)
 {
 }