Example #1
0
        //=====VEHICLESERVICE=================================================================================
        IVehicleService IVehicleServiceRepository.GetById(int serviceId)
        {
            var getVehicleService     = datacontext.VehicleServices.Where(s => s.VehicleServiceId == serviceId).FirstOrDefault();
            var vehicleServiceFactory = new VehicleServiceFactory();

            IVehicleService vehicleService = vehicleServiceFactory.CreateService(getVehicleService.VehicleServiceId,
                                                                                 GetVehicleById((int)getVehicleService.VehicleId),
                                                                                 (DateTime)getVehicleService.ServiceDate,
                                                                                 getVehicleService.VehicleService_Type,
                                                                                 getVehicleService.IsServiceCompleted);

            return(vehicleService);
        }
        public IHttpActionResult UpdateVehicleService(VehicleServiceDto update)
        {
            VehicleServiceFactory vehicleServiceFactory = new VehicleServiceFactory();
            IVehicleService       vehicleService        = vehicleServiceFactory.CreateService(update.VehicleServiceId,
                                                                                              null,
                                                                                              update.ServiceDate,
                                                                                              update.ServiceType,
                                                                                              update.IsServiceCompleted);

            vehicleServiceRepository_.Update(vehicleService);

            return(Ok());
        }
        public IHttpActionResult CreateVehicleServiceForManyVehicles(VehicleServiceDto request)
        {
            VehicleServiceFactory vehicleServiceFactory = new VehicleServiceFactory();
            IVehicleService       vehicleService        = vehicleServiceFactory.CreateService(request.VehicleServiceId,
                                                                                              (IVehicle)request.VehicleList,
                                                                                              request.ServiceDate,
                                                                                              request.ServiceType,
                                                                                              request.IsServiceCompleted);

            foreach (var vehicle in request.VehicleList)
            {
                vehicleServiceRepository_.Create(vehicleService, vehicle.VehicleId);
            }

            return(Ok());
        }
        public IHttpActionResult CreateVehicleService(VehicleServiceDto request)
        {
            VehicleServiceFactory vehicleServiceFactory = new VehicleServiceFactory();
            IVehicleService       vehicleService        = vehicleServiceFactory.CreateService(request.VehicleServiceId,
                                                                                              null,
                                                                                              request.ServiceDate,
                                                                                              request.ServiceType,
                                                                                              request.IsServiceCompleted);

            if (vehicleServiceRepository_.Create(vehicleService, request.VehicleId))
            {
                return(Ok());
            }
            else
            {
                return(NotFound());
            }
        }
Example #5
0
        //=====VEHICLESERVICE=================================================================================
        public IEnumerable <IVehicleService> GetAllVehicleServices(bool finnishedServices)
        {
            var vehicleServiceList    = new List <IVehicleService>();
            var vehicleServiceFactory = new VehicleServiceFactory();

            foreach (var entity in datacontext.VehicleServices.ToList())
            {
                if (entity.IsServiceCompleted == finnishedServices)
                {
                    IVehicleService service = vehicleServiceFactory.CreateService(entity.VehicleServiceId,
                                                                                  GetVehicleById((int)entity.VehicleId),
                                                                                  (DateTime)entity.ServiceDate,
                                                                                  entity.VehicleService_Type,
                                                                                  entity.IsServiceCompleted);
                    vehicleServiceList.Add(service);
                }
            }
            return(vehicleServiceList);
        }
Example #6
0
        //=====VEHICLESERVICE=================================================================================
        public IVehicleService GetVehicleServiceByVehicleId(int vehicleId)
        {
            var getVehicleService     = datacontext.VehicleServices.Where(s => s.VehicleId == vehicleId).Where(f => f.IsServiceCompleted == false).FirstOrDefault();
            var vehicleServiceFactory = new VehicleServiceFactory();

            if (getVehicleService != null)
            {
                IVehicleService vehicleService = vehicleServiceFactory.CreateService(getVehicleService.VehicleServiceId,
                                                                                     GetVehicleById((int)getVehicleService.VehicleId),
                                                                                     (DateTime)getVehicleService.ServiceDate,
                                                                                     getVehicleService.VehicleService_Type,
                                                                                     getVehicleService.IsServiceCompleted);

                return(vehicleService);
            }
            else
            {
                return(null);
            }
        }
Example #7
0
        //====================================================================================================

        public IEnumerable <IVehicleService> GetVehiclesServiceHistory(int vehicleId)
        {
            var vehicleServiceList    = new List <IVehicleService>();
            var vehicleServiceFactory = new VehicleServiceFactory();

            foreach (var entity in datacontext.VehicleServices.Where(c => c.VehicleId == vehicleId).ToList())
            {
                if (entity.IsServiceCompleted == true)
                {
                    IVehicleService service = vehicleServiceFactory.CreateService(entity.VehicleServiceId,
                                                                                  GetVehicleById((int)entity.VehicleId),
                                                                                  (DateTime)entity.ServiceDate,
                                                                                  entity.VehicleService_Type,
                                                                                  entity.IsServiceCompleted);

                    vehicleServiceList.Add(service);
                }
            }
            return(vehicleServiceList);
        }