Beispiel #1
0
        public IActionResult OnGet(int carId)
        {
            CarServiceVM = new CarServiceViewModel()
            {
                Car     = db.Cars.Include(m => m.ApplicationUser).Where(m => m.Id == carId).FirstOrDefault(),
                Service = new Service()
            };

            List <string> ListServiceTypeInShoopingCart = db.ServiceShoopingCarts
                                                          .Include(m => m.ServiceType).Where(m => m.CarId == carId)
                                                          .Select(m => m.ServiceType.Name).ToList();

            IQueryable <ServiceType> ListServiceType = from s in db.ServiceTypes
                                                       where !(ListServiceTypeInShoopingCart.Contains(s.Name))
                                                       select s;

            CarServiceVM.ServiceTypes = ListServiceType.ToList();

            CarServiceVM.ServiceShoopingCarts = db.ServiceShoopingCarts.Include(m => m.ServiceType)
                                                .Where(m => m.CarId == carId).ToList();

            foreach (var item in CarServiceVM.ServiceShoopingCarts)
            {
                CarServiceVM.Service.TotalPrice += item.ServiceType.Price;
            }

            return(Page());
        }
Beispiel #2
0
        public async Task <IActionResult> OnGet(int carId)
        {
            CarServiceVM = new CarServiceViewModel
            {
                Car = await _db.Car.Include(c => c.Application)
                      .FirstOrDefaultAsync(c => c.Id == carId),
                ServiceHeader = new Models.ServiceHeader()
            };

            List <String> lstServiceTypeInShoppoingCart = _db.ServiceShoppingCart
                                                          .Include(c => c.ServiceType)
                                                          .Where(c => c.CardId == carId)
                                                          .Select(c => c.ServiceType.Name).ToList();


            IQueryable <ServiceType> lstService = from s in _db.ServiceType
                                                  where !(lstServiceTypeInShoppoingCart.Contains(s.Name))
                                                  select s;


            CarServiceVM.ServiceTypesList = lstService.ToList();

            CarServiceVM.ServiceShoppingCart = _db.ServiceShoppingCart
                                               .Include(c => c.ServiceType).Where(c => c.CardId == carId).ToList();
            CarServiceVM.ServiceHeader.TotalPrice = 0;

            foreach (var item in CarServiceVM.ServiceShoppingCart)
            {
                CarServiceVM.ServiceHeader.TotalPrice += item.ServiceType.Price;
            }

            return(Page());
        }
Beispiel #3
0
        public async Task <IActionResult> OnGetAsync(int carId)
        {
            CarServiceVM = new CarServiceViewModel()
            {
                Car           = await _contex.Cars.Include(x => x.ApplicationUser).FirstOrDefaultAsync(c => c.Id == carId),
                ServiceHeader = new Models.ServiceHeader()
            };

            List <string> listServiceTypeInShoppingCar = await _contex.ServiceShoppingCars
                                                         .Include(x => x.ServiceType)
                                                         .Where(x => x.CarId == carId)
                                                         .Select(x => x.ServiceType.Name).ToListAsync();

            IQueryable <ServiceType> listServiceType = from s in _contex.ServiceTypes
                                                       where !(listServiceTypeInShoppingCar.Contains(s.Name))
                                                       select s;

            CarServiceVM.ServiceTypes = listServiceType.ToList();

            CarServiceVM.ServiceShoppingCars = await _contex.ServiceShoppingCars
                                               .Include(x => x.ServiceType)
                                               .Where(x => x.CarId == carId).ToListAsync();

            CarServiceVM.ServiceHeader.TotalPrice = 0;

            foreach (var item in CarServiceVM.ServiceShoppingCars)
            {
                CarServiceVM.ServiceHeader.TotalPrice += item.ServiceType.Price;
            }

            return(Page());
        }
Beispiel #4
0
        public ActionResult ViewService(Car car)
        {
            var            serv          = service_cont.Services.ToList();
            var            servType      = service_cont.ServiceTypes.ToList();
            List <Service> listofservice = new List <Service>();

            //if (serv.Count < 5)
            //{
            foreach (var item in serv)
            {
                if (item.CarId == car.Id)
                {
                    listofservice.Add(item);
                }
            }
            //}
            var viewModel = new CarServiceViewModel
            {
                Cars         = car,
                PastServices = listofservice,
                serviceTypes = servType
            };

            //var viewModel = new CarServiceEnumerableViewModel
            //{
            //    //carId = car.Id,
            //    Cars = car,
            //    Services = service
            //};
            return(View(viewModel));
        }
Beispiel #5
0
        // GET: Service
        public ActionResult ServiceForm(Car car)
        {
            var viewModel = new CarServiceViewModel
            {
                Cars = car,
            };

            return(View(viewModel));
        }
Beispiel #6
0
        public ActionResult NewService(CarServiceViewModel cs)
        {
            cs.Services.CarId     = cs.Cars.Id;
            cs.Services.DateAdded = DateTime.Today.Date;
            service_cont.Services.Add(cs.Services);
            service_cont.SaveChanges();
            var car = service_cont.Cars.Find(cs.Cars.Id);

            return(RedirectToAction("ViewService", "Service", car));
        }
Beispiel #7
0
        public IActionResult GetServiceHistoryDetails(string Id, int sId, int cId)
        {
            ViewBag.Name = User.Identity.Name;
            var ServiceDetails = new CarServiceViewModel
            {
                ServiceHistory   = _sparkDbContext.CarServiceHistories.Include(c => c.Car).Where(c => c.Id == sId).ToList(),
                ApplicationUsers = _applicationDbContext.ApplicationUsers.Where(x => x.Email == Id).FirstOrDefault(),
                ServiceDetails   = _sparkDbContext.CarServiceDetails.Include(c => c.ServiceType).Where(e => e.ServiceHistoryId == sId).ToList(),
                Cart             = _sparkDbContext.ServiceShoppingCarts.Include(s => s.ServiceType).Include(c => c.Car).Where(c => c.CarId == cId).ToList()
            };

            return(View(ServiceDetails));
        }
Beispiel #8
0
        public IActionResult GetServiceHistory(string Id, int carId)
        {
            var ServiceViewModel = new CarServiceViewModel
            {
                ServiceHistory   = _sparkDbContext.CarServiceHistories.Include(c => c.Car).Where(c => c.CarId == carId).ToList(),
                ApplicationUsers = _applicationDbContext.ApplicationUsers.Where(e => e.Email == Id).FirstOrDefault(),
                Cart             = _sparkDbContext.ServiceShoppingCarts.Include(s => s.ServiceType).Include(c => c.Car).Where(c => c.CarId == carId).ToList(),
                ServiceTypes     = _sparkDbContext.CarServiceTypes.ToList(),
                Car = _sparkDbContext.Cars.Where(c => c.CarId == carId).FirstOrDefault(),
                ServiceHistoryyy = _sparkDbContext.CarServiceHistories.Include(c => c.Car).Where(c => c.CarId == carId).FirstOrDefault(),
            };

            return(View(ServiceViewModel));
        }
Beispiel #9
0
        public IActionResult CreateNewService(int sId, string Id, ServiceShoppingCart serviceShoppingCart)
        {
            ViewBag.Service = _sparkDbContext.CarServiceTypes.ToList();
            var NewService = new CarServiceViewModel
            {
                Car              = _sparkDbContext.Cars.Where(c => c.CarId == sId).FirstOrDefault(),
                ServiceHistory   = _sparkDbContext.CarServiceHistories.Include(c => c.Car).ToList(),
                ApplicationUsers = _applicationDbContext.ApplicationUsers.Where(c => c.Email == Id).FirstOrDefault(),
                ServiceTypes     = _sparkDbContext.CarServiceTypes.ToList(),
                Cart             = _sparkDbContext.ServiceShoppingCarts.Include(s => s.ServiceType).Include(c => c.Car).Where(c => c.CarId == sId).ToList(),
                ServiceHistoryyy = _sparkDbContext.CarServiceHistories.Include(c => c.Car).FirstOrDefault()
            };

            return(View(NewService));
        }
Beispiel #10
0
        public async Task <IActionResult> OnGet(int carId)
        {
            CarServiceVM = new CarServiceViewModel
            {
                Car           = await _db.Car.Include(c => c.ApplicationUser).FirstOrDefaultAsync(c => c.Id == carId),
                ServiceHeader = new Models.ServiceHeader()
            };

            cv = _db.CommonValues.Find(1);

            List <String> lstServiceTypeInShoppingCart = _db.ServiceShoppingCart
                                                         .Include(c => c.ServiceType)
                                                         .Where(c => c.CarId == carId)
                                                         .Select(c => c.ServiceType.Name)
                                                         .ToList();

            IQueryable <ServiceType> lstService = from s in _db.ServiceType
                                                  where !(lstServiceTypeInShoppingCart.Contains(s.Name))
                                                  select s;

            CarServiceVM.ServiceTypesList = lstService.ToList();

            CarServiceVM.ServiceShoppingCart = _db.ServiceShoppingCart
                                               .Include(c => c.ServiceType)
                                               .Where(c => c.CarId == carId)
                                               .ToList();
            CarServiceVM.ServiceHeader.TotalPrice = 0;
            CarServiceVM.ServiceHeader.Tax        = 0;


            foreach (var item in CarServiceVM.ServiceShoppingCart)
            {
                CarServiceVM.ServiceHeader.TotalPrice += item.ServiceType.Price * item.Quantity;
                CarServiceVM.ServiceHeader.TotalPrice  = Math.Round(CarServiceVM.ServiceHeader.TotalPrice, 2);
                CarServiceVM.ServiceHeader.Tax         = CarServiceVM.ServiceHeader.TotalPrice * cv.iva;
                CarServiceVM.ServiceHeader.Tax         = Math.Round(CarServiceVM.ServiceHeader.Tax, 2);
                CarServiceVM.ServiceHeader.EnvCharge   = cv.envCharge;
                CarServiceVM.ServiceHeader.FullPrice   = CarServiceVM.ServiceHeader.Tax + CarServiceVM.ServiceHeader.TotalPrice + CarServiceVM.ServiceHeader.EnvCharge;
                CarServiceVM.ServiceHeader.FullPrice   = Math.Round(CarServiceVM.ServiceHeader.FullPrice, 2);
            }

            return(Page());
        }
Beispiel #11
0
        public async Task <IActionResult> OnGetAsync(int carId)
        {
            // Car Service Model has a car and serice header.
            CarServiceVM = new CarServiceViewModel
            {
                Car           = await _db.Car.Include(c => c.ApplicationUser).FirstOrDefaultAsync(c => c.Id == carId),
                ServiceHeader = new Models.ServiceHeader()
            };

            // Get all the service types for this car from the cart
            // Inclucde from shoping cart the service types where the car id matches.
            // Return just the service type name and convert to a list data structure.
            List <String> listServiceTypeInShoppingCart =
                _db.ServiceShoppingCart.Include(c => c.ServiceType)
                .Where(c => c.CarId == carId)
                .Select(c => c.ServiceType.Name)
                .ToList();

            // I think this is getting all the service types that are not already in the cart.
            // Used for the list of services in the drop down.
            IQueryable <ServiceType> listService = from s in _db.ServcieType
                                                   where !(listServiceTypeInShoppingCart.Contains(s.Name))
                                                   select s;

            CarServiceVM.ServiceTypeList = listService.ToList();

            // Get the shopping cart items for our car and convert to a list.
            CarServiceVM.ServiceShoppingCart =
                _db.ServiceShoppingCart.Include(c => c.ServiceType).Where(c => c.CarId == carId).ToList();

            //Add up all the costs
            CarServiceVM.ServiceHeader.TotalPrice = 0;

            foreach (var item in CarServiceVM.ServiceShoppingCart)
            {
                CarServiceVM.ServiceHeader.TotalPrice += item.ServiceType.Price;
            }

            return(Page());
        }
Beispiel #12
0
        public async Task <IActionResult> OnGetAsync(int?carId)
        {
            CarServiceViewModel = new CarServiceViewModel
            {
                Car           = await _db.Car.Include(c => c.ApplicationUser).FirstOrDefaultAsync(c => c.Id == carId),
                ServiceHeader = new Models.ServiceHeader()
            };

            List <String> listServiceTypeInShoppingCart = _db.ServiceShoppingCart
                                                          .Include(c => c.ServiceType)
                                                          .Where(c => c.CarId == carId)
                                                          .Select(c => c.ServiceType.Name)
                                                          .ToList();

            IQueryable <ServiceType> listService = from s in _db.ServiceType
                                                   where !(listServiceTypeInShoppingCart.Contains(s.Name))
                                                   select s;

            CarServiceViewModel.ServiceTypesList         = listService.ToList();
            CarServiceViewModel.ServiceShoppingCart      = _db.ServiceShoppingCart.Include(c => c.ServiceType).Where(c => c.CarId == carId).ToList();
            CarServiceViewModel.ServiceHeader.TotalPrice = CarServiceViewModel.ServiceShoppingCart.Sum(item => item.ServiceType.Price);

            return(Page());
        }
        // GET: UserPackages/Details/5
        public ActionResult Details(int?id)
        {
            DateTime cTime   = DateTime.Now;
            DateTime nTime   = cTime.AddDays(2);
            double   dayDiff = 0;

            dayDiff = nTime.Subtract(cTime).TotalDays;

            //Response.Write("dayDiff : " + dayDiff);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            UserPackage userPackage = db.UserPackages.Find(id);

            if (userPackage == null)
            {
                return(HttpNotFound());
            }

            DateTime currentDate = DateTime.Now;

            UserPackageDetailViewModel userPackageModel = new UserPackageDetailViewModel();

            userPackageModel.Id               = userPackage.Id;
            userPackageModel.ActualPrice      = userPackage.ActualPrice;
            userPackageModel.TotalPrice       = userPackage.TotalPrice;
            userPackageModel.TaxAmount        = userPackage.TaxAmount;
            userPackageModel.TipAmount        = userPackage.TipAmount;
            userPackageModel.SubscriptionType = SubscriptionTypeInfo.GetSubscriptionTypeInfo(userPackage.SubscriptionTypeId);
            userPackageModel.ServiceDay       = userPackage.ServiceDay;
            userPackageModel.TimeSlot         = userPackage.GaragesTimeingSlotId.HasValue ? userPackage.GargesTimeingSlot.SlotTimeing : "";
            userPackageModel.SubscribedDate   = userPackage.SubscribedDate;
            userPackageModel.IsActive         = userPackage.IsActive;

            userPackageModel.Package = new PackageDetailViewModel();
            userPackageModel.Package.Package_Name        = userPackage.Package.Package_Name;
            userPackageModel.Package.Package_Description = userPackage.Package.Package_Description;


            userPackageModel.Services = new List <CarServiceViewModel>();

            var ServiceList = userPackage.Package.Package_Services.Select(s => s.Service).ToList();

            foreach (var service in ServiceList)
            {
                CarServiceViewModel serviceModel = new CarServiceViewModel();
                serviceModel.ServiceID    = service.ServiceID;
                serviceModel.Service_Name = service.Service_Name;
                userPackageModel.Services.Add(serviceModel);
            }

            if (userPackage.UserPackagesAddons.Count > 0)
            {
                foreach (var userPackagesAddon in userPackage.UserPackagesAddons.Where(a => a.NextServiceDate == userPackage.NextServiceDate).ToList())
                {
                    CarServiceViewModel serviceModel = new CarServiceViewModel();
                    serviceModel.ServiceID    = userPackagesAddon.Service.ServiceID;
                    serviceModel.Service_Name = userPackagesAddon.Service.Service_Name;
                    serviceModel.IsAddOn      = true;
                    userPackageModel.Services.Add(serviceModel);
                }
            }


            // Available AddOns List

            /// Prepare Car Model
            ///

            userPackageModel.AvailableAddOns = new List <AddOnsServiceModel>();
            var addOnsService = db.Services.Where(s => s.IsAddOn).ToList();

            foreach (var addOns in addOnsService)
            {
                userPackageModel.AvailableAddOns.Add(new AddOnsServiceModel()
                {
                    ServiceID           = addOns.ServiceID,
                    Service_Name        = addOns.Service_Name,
                    Service_Description = addOns.Service_Description,
                    Service_Price       = addOns.Service_Price,
                });
            }

            cTime   = DateTime.Now;
            nTime   = Convert.ToDateTime(userPackage.NextServiceDate);
            dayDiff = 0;
            dayDiff = nTime.Subtract(cTime).TotalDays;
            userPackageModel.AddonsAvailableForEdit = dayDiff > 1 ? true : false;

            CarViewModel carModel = new CarViewModel();

            var item = db.CarUsers.Where(c => c.CarId == userPackage.CarId).SingleOrDefault();

            if (item == null)
            {
                return(RedirectToAction("Index"));
            }

            carModel               = new CarViewModel();
            carModel.AutoRenewal   = item.AutoRenewal;
            carModel.CarId         = item.CarId;
            carModel.Color         = item.Color;
            carModel.DisplayName   = item.DisplayName;
            carModel.GarageId      = item.GarageId;
            carModel.IsDeleted     = item.IsDeleted;
            carModel.LicenseNumber = item.LicenseNumber;
            carModel.Make          = item.Make;
            carModel.PurchaseYear  = item.PurchaseYear;
            //carModel.Type = item.Type; //comment by circus
            carModel.UserId = item.UserId;

            // carModel.CarType = item.CarType.Description; //comment by circus
            if (item.Garage != null)
            {
                carModel.Garage = item.Garage.Garage_Name;
            }

            userPackageModel.CarModel = carModel;


            /// Prepare Payments Historys
            var paypalAutoPaymentList = db.PaypalAutoPayments.Where(p => p.UserPackageID == id && p.IsPaid == true).ToList();

            if (paypalAutoPaymentList.Count > 0)
            {
                foreach (var payment in paypalAutoPaymentList)
                {
                    PaypalAutoPaymentsViewModel paymentViewModel = new PaypalAutoPaymentsViewModel();
                    paymentViewModel.Id              = payment.Id;
                    paymentViewModel.ReferenceID     = payment.ReferenceID;
                    paymentViewModel.TrasactionID    = payment.TrasactionID;
                    paymentViewModel.TransactionDate = payment.TransactionDate;
                    paymentViewModel.GrossAmount     = payment.GrossAmount;
                    paymentViewModel.CreatedOn       = payment.CreatedOn;
                    paymentViewModel.ServiceDate     = payment.ServiceDate;
                    userPackageModel.PaymentHistorys.Add(paymentViewModel);
                }

                var NextPaymentPaid = paypalAutoPaymentList.FirstOrDefault(p => p.ServiceDate == userPackage.NextServiceDate);
                userPackageModel.AddonsAvailableForEdit = NextPaymentPaid == null ? true : false;
            }

            return(View(userPackageModel));
        }
 public CarServiceWindow(RECEPTION carReception)
 {
     InitializeComponent();
     this.DataContext = (carServiceViewModel = new CarServiceViewModel(carReception));
 }
 public CarServiceWindow()
 {
     InitializeComponent();
     this.DataContext = (carServiceViewModel = new CarServiceViewModel());
 }
Beispiel #16
0
        public ActionResult Edit(int id)
        {
            CarViewModel carModel = new CarViewModel();

            var item = db.CarUsers.Where(c => c.CarId == id).SingleOrDefault();

            if (item == null)
            {
                return(RedirectToAction("Index"));
            }

            carModel               = new CarViewModel();
            carModel.AutoRenewal   = item.AutoRenewal;
            carModel.CarId         = item.CarId;
            carModel.Color         = item.Color;
            carModel.DisplayName   = item.DisplayName;
            carModel.GarageId      = item.GarageId;
            carModel.IsDeleted     = item.IsDeleted;
            carModel.LicenseNumber = item.LicenseNumber;
            carModel.Make          = item.Make;
            carModel.PurchaseYear  = item.PurchaseYear;
            //carModel.Type = item.Type; //comment by circus
            carModel.UserId = item.UserId;

            // carModel.CarType = item.CarType.Description; //comment by circus
            if (item.Garage != null)
            {
                carModel.Garage = item.Garage.Garage_Name;
            }

            if (item.UserPackages.Count > 0)
            {
                var UserPackagesList = item.UserPackages.Where(i => i.PaymentRecieved == true).ToList();
                if (UserPackagesList.Count > 0)
                {
                    carModel.UserPackages = new List <UserPackageViewModel>();
                    foreach (var userPackage in UserPackagesList)
                    {
                        UserPackageViewModel userPackageModel = new UserPackageViewModel();
                        userPackageModel.Id             = userPackage.Id;
                        userPackageModel.ActualPrice    = userPackage.ActualPrice;
                        userPackageModel.TotalPrice     = userPackage.TotalPrice;
                        userPackageModel.TipAmount      = userPackage.TipAmount;
                        userPackageModel.ServiceDay     = userPackage.ServiceDay;
                        userPackageModel.TimeSlot       = userPackage.GaragesTimeingSlotId.HasValue ? userPackage.GargesTimeingSlot.SlotTimeing : "";
                        userPackageModel.SubscribedDate = userPackage.SubscribedDate;

                        userPackageModel.Package = new PackageViewModel();
                        userPackageModel.Package.Package_Name        = userPackage.Package.Package_Name;
                        userPackageModel.Package.Package_Description = userPackage.Package.Package_Description;


                        userPackageModel.Services = new List <CarServiceViewModel>();

                        var ServiceList = userPackage.Package.Package_Services.Select(s => s.Service).ToList();
                        foreach (var service in ServiceList)
                        {
                            CarServiceViewModel serviceModel = new CarServiceViewModel();
                            serviceModel.Service_Name = service.Service_Name;
                            userPackageModel.Services.Add(serviceModel);
                        }

                        if (userPackage.UserPackagesAddons.Count > 0)
                        {
                            foreach (var userPackagesAddon in userPackage.UserPackagesAddons)
                            {
                                CarServiceViewModel serviceModel = new CarServiceViewModel();
                                serviceModel.Service_Name = userPackagesAddon.Service.Service_Name;
                                serviceModel.IsAddOn      = true;
                                userPackageModel.Services.Add(serviceModel);
                            }
                        }



                        /// Prepare Payments Historys
                        var paypalAutoPaymentList = db.PaypalAutoPayments.Where(p => p.UserPackageID == userPackage.Id).ToList();
                        if (paypalAutoPaymentList.Count > 0)
                        {
                            foreach (var payment in paypalAutoPaymentList)
                            {
                                PaypalAutoPaymentsViewModel paymentViewModel = new PaypalAutoPaymentsViewModel();
                                paymentViewModel.Id              = payment.Id;
                                paymentViewModel.ReferenceID     = payment.ReferenceID;
                                paymentViewModel.TrasactionID    = payment.TrasactionID;
                                paymentViewModel.TransactionDate = payment.TransactionDate;
                                paymentViewModel.IsPaid          = payment.IsPaid;
                                paymentViewModel.PaymentStatus   = payment.PaymentStatus;
                                paymentViewModel.GrossAmount     = payment.GrossAmount;
                                paymentViewModel.CreatedOn       = payment.CreatedOn;
                                paymentViewModel.ServiceDate     = payment.ServiceDate;
                                userPackageModel.PaymentHistorys.Add(paymentViewModel);
                            }
                        }

                        carModel.UserPackages.Add(userPackageModel);
                    }
                }
            }



            return(View(carModel));
        }