Example #1
0
        public ActionResult UpdateVehicleService(VehicleServiceModel updateService)
        {
            if (updateService.ServiceDate.Year < minimumYear)
            {
                ViewBag.Message = "You did not enter a valid date";
                return(View("Error"));
            }
            var vehicleServiceUpdateRequest = new VehicleServiceDto
            {
                VehicleServiceId   = updateService.VehicleServiceId,
                VehicleId          = updateService.VehicleId,
                ServiceDate        = updateService.ServiceDate,
                ServiceType        = updateService.ServiceType,
                IsServiceCompleted = updateService.IsServiceCompleted
            };
            string jsonCreateCustomer = JsonConvert.SerializeObject(vehicleServiceUpdateRequest);
            var    httpContent        = new StringContent(jsonCreateCustomer, Encoding.UTF8, "application/json");

            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Session["tokenkey"].ToString());

                var response = client.PostAsync(new Uri(_endpoints.UpdateVehicleService), httpContent).Result;

                if (response.StatusCode != System.Net.HttpStatusCode.OK)
                {
                    return(View("Error"));
                }
            }
            ViewBag.Message = "Vehicleservice has been updated";
            return(View("Success"));
        }
        public IHttpActionResult GetVehicleById(VehicleDto vehicle)
        {
            var getvehicle = vehicleRepository_.GetVehicleById(vehicle.VehicleId);
            var getService = vehicleServiceRepository_.GetVehicleServiceByVehicleId(vehicle.VehicleId);

            var getdate = new VehicleServiceDto();

            if (getService != null)
            {
                getdate.ServiceDate = getService.ServiceDate;
            }

            if (getvehicle != null)
            {
                var response = new VehicleDto()
                {
                    VehicleId          = getvehicle.VehicleId,
                    RegistrationNumber = getvehicle.RegistrationNumber,
                    Model             = getvehicle.Model,
                    Brand             = getvehicle.Brand,
                    YearlyFee         = getvehicle.YearlyFee,
                    VehicleType       = getvehicle.VehicleType,
                    IsRegistered      = getvehicle.IsRegistered,
                    Weight            = getvehicle.Weight,
                    FirstUseInTraffic = getvehicle.FirstUseInTraffic,
                    BookedService     = getdate.ServiceDate
                };
                return(Ok(response));
            }
            else
            {
                return(NotFound());
            }
        }
Example #3
0
        public ActionResult GetVehicleServiceById(GetVehicleServicesModel serviceId)
        {
            var vehicleServiceList = new List <GetVehicleServicesModel>();
            var request            = new VehicleServiceDto {
                VehicleServiceId = serviceId.VehicleServiceId
            };

            string jsonrequest = JsonConvert.SerializeObject(request);
            var    httpcontent = new StringContent(jsonrequest, Encoding.UTF8, "application/json");

            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Session["tokenkey"].ToString());

                var response = client.PostAsync(new Uri(_endpoints.GetVehicleService), httpcontent).Result;

                if (response != null)
                {
                    var jsonGetVehicleService = response.Content.ReadAsStringAsync().Result;
                    var responseDto           = JsonConvert.DeserializeObject <VehicleServiceDto>(jsonGetVehicleService);

                    var result = new GetVehicleServicesModel
                    {
                        VehicleServiceId = responseDto.VehicleServiceId,
                        ServiceDate      = responseDto.ServiceDate,
                        ServiceType      = responseDto.ServiceType
                    };
                    vehicleServiceList.Add(result);
                    ViewBag.Message = vehicleServiceList;
                }
            }
            return(View("DetailVehicleService", vehicleServiceList.First()));
        }
Example #4
0
        private VehicleServiceDto GetServiceForDto(Service Vehicleservice)
        {
            VehicleServiceDto service = new VehicleServiceDto
            {
                ServiceDate    = Vehicleservice.ServiceDate,
                ServiceHistory = Vehicleservice.ServiceHistory
            };

            return(service);
        }
        public IHttpActionResult DeleteVehicleService(VehicleServiceDto serviceModel)
        {
            int serviceid = serviceModel.VehicleServiceId;
            int vehicleid = serviceModel.VehicleId;

            vehicleRepository_.DeleteBookedService(vehicleid);
            vehicleServiceRepository_.DeleteService(serviceid);

            return(Ok());
        }
        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 GetVehicleServiceById(VehicleServiceDto vehicleService)
        {
            var vehicleServiceRequest = vehicleServiceRepository_.GetById(vehicleService.VehicleServiceId);

            var respons = new VehicleServiceDto()
            {
                VehicleServiceId   = vehicleServiceRequest.ServiceId,
                VehicleId          = vehicleService.VehicleId,
                ServiceDate        = vehicleServiceRequest.ServiceDate,
                ServiceType        = vehicleServiceRequest.ServiceType,
                IsServiceCompleted = vehicleServiceRequest.IsServiceCompleted
            };

            return(Ok(respons));
        }
        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());
            }
        }
        public IHttpActionResult GetVehicleServiceByVehicleId(VehicleDto vehicle)
        {
            var vehicleService = vehicleServiceRepository_.GetVehicleServiceByVehicleId(vehicle.VehicleId);

            if (vehicleService != null)
            {
                var respons = new VehicleServiceDto()
                {
                    VehicleServiceId = vehicleService.ServiceId,
                    VehicleId        = vehicle.VehicleId,
                    ServiceDate      = vehicleService.ServiceDate,
                    ServiceType      = vehicleService.ServiceType,
                };
                return(Ok(respons));
            }
            else
            {
                return(NotFound());
            }
        }
Example #11
0
        public ActionResult BookVehicleServiceForManyVehicles(BookServiceForTwoVehicles service)
        {
            List <VehicleDto> vehicleList = new List <VehicleDto>();

            vehicleList.Add(new VehicleDto {
                VehicleId = service.VehicleIdOne
            });
            vehicleList.Add(new VehicleDto {
                VehicleId = service.VehicleIdTwo
            });
            var createVehicleServiceRequest = new VehicleServiceDto
            {
                VehicleList        = vehicleList,
                ServiceDate        = service.ServiceDate,
                ServiceType        = service.ServiceType,
                IsServiceCompleted = false
            };

            string jsonCreateVehicleService = JsonConvert.SerializeObject(createVehicleServiceRequest);

            var httpContent = new StringContent(jsonCreateVehicleService, Encoding.UTF8, "application/json");

            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Session["tokenkey"].ToString());

                var response = client.PostAsync(new Uri(_endpoints.CreateVehicleService), httpContent).Result;

                if (response.StatusCode != System.Net.HttpStatusCode.OK)
                {
                    return(View("Error"));
                }
            }

            ViewBag.Message("Service has been booked");
            return(View("Success"));
        }
Example #12
0
        public ActionResult DeleteVehicleService(GetVehicleServicesModel deleteService)
        {
            var request = new VehicleServiceDto {
                VehicleServiceId = deleteService.VehicleServiceId,
                VehicleId        = deleteService.VehicleId
            };

            string jsonDeleteVehicleService = JsonConvert.SerializeObject(request);
            var    httpcontent = new StringContent(jsonDeleteVehicleService, Encoding.UTF8, "application/json");

            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Session["tokenkey"].ToString());

                var response = client.PostAsync(new Uri(_endpoints.DeleteVehicleService), httpcontent).Result;

                if (response.StatusCode != System.Net.HttpStatusCode.OK)
                {
                    return(View("Error"));
                }
            }
            ViewBag.Message = "Vehicleservice has been deleted";
            return(View("Success"));
        }