Exemplo n.º 1
0
        //
        // GET: /Guest/
        public ActionResult Index()
        {
            domaninCars = guest.CarsCondition();

            allCars = domaninCars.Select(c => new CarView(c));

            allmodels = guest.AllModels().Select(c => new ModelView(c));

            allDeals = manager.AllPurchases().Select(d => new PurchaseView(d));

            List <SelectListItem> modelsItems   = new List <SelectListItem>();
            List <SelectListItem> manufacsItems = new List <SelectListItem>();

            foreach (var model in allmodels)
            {
                modelsItems.Add(new SelectListItem {
                    Text = model.ModelName, Value = model.ID.ToString()
                });
            }

            ViewBag.model   = modelsItems;
            ViewBag.manufac = manufacsItems;

            return(View());
        }
Exemplo n.º 2
0
 public ActionResult ListPurchased()
 {
     try
     {
         if (User == null || string.IsNullOrEmpty(User.Identity.Name))
         {
             return(PartialView(new List <PurchaseView>()));
         }
         ManagerQuery manager      = new ManagerQuery();
         var          UserID       = manager.GetAllUsers().Where(p => p.UserName == User.Identity.Name).Select(p => p.ID).FirstOrDefault();
         var          model        = new List <PurchaseView>();
         var          lstPurchased = manager.AllPurchases().Where(p => p.UserId.HasValue && p.UserId.Value == UserID && p.PurchasesStatus.HasValue && p.PurchasesStatus.Value == 1).ToList();
         if (lstPurchased.Count > 0)
         {
             foreach (var pur in lstPurchased)
             {
                 var purView = new PurchaseView(pur);
                 purView.Availlability = (pur.CarID.HasValue && pur.PurchaseDate.HasValue && pur.ReturnDate.HasValue) ? CheckCarAvailability(pur.PurchaseDate.Value, pur.ReturnDate.Value, pur.CarID.Value) : false;
                 model.Add(purView);
             }
         }
         return(PartialView(model));
     }
     catch
     {
         return(PartialView(new List <PurchaseView>()));
     }
 }
Exemplo n.º 3
0
        public ActionResult Confimation(int dealID)
        {
            //var deals = Session[DEALS_IN_THE_BUSKET] as List<PurchaseView>;

            //var currenDeal = deals.Where(d => d.ID == dealID).FirstOrDefault();

            //deals.Remove(currenDeal);

            //Session[DEALS_IN_THE_BUSKET] = deals;

            //_customer.PurcaseConfirmation(currenDeal.ReturnDateDetails());

            //TempData["Success"] = "Reservation Completed!";

            //return RedirectToAction("PreviousReservations");
            try
            {
                if (User == null || string.IsNullOrEmpty(User.Identity.Name))
                {
                    return(Json(new { IsOk = 0 }, JsonRequestBehavior.AllowGet));
                }
                ManagerQuery manager    = new ManagerQuery();
                var          _Purchases = manager.AllPurchases().Where(p => p.ID == dealID).FirstOrDefault();
                _Purchases.PurchasesStatus = 1;
                manager.UpdatePurchase(_Purchases);
                return(Json(new { IsOk = 1, Url = Url.Action("MyBusket", "Customer") }, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                return(Json(new { IsOk = -1 }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 4
0
        public JsonResult HelpAjax()
        {
            allCars = _manager.AllCars().Select(c => new CarView(c));

            allmodels = guest.AllModels().Select(c => new ModelView(c));

            allDeals = _manager.AllPurchases().Select(d => new PurchaseView(d));

            allCustomers = _manager.AllCustomers().Select(u => new UserView(u));

            allEmployees = _manager.AllEmployees().Select(u => new UserView(u));

            var managerHelper = new CalcModel();

            managerHelper.AllCarModels = allmodels;

            managerHelper.AllDeals = allDeals;

            managerHelper.AllCustomers = allCustomers;

            managerHelper.AllEmployees = allEmployees;

            managerHelper.AllCars = allCars;

            return(Json(managerHelper, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 5
0
        private bool CheckCarAvailability(DateTime sDateStart, DateTime sDateEnd, int CarID)
        {
            ManagerQuery manager   = new ManagerQuery();
            DateTime     DateStart = new DateTime(sDateStart.Year, sDateStart.Month, sDateStart.Day);
            DateTime     DateEnd   = new DateTime(sDateEnd.Year, sDateEnd.Month, sDateEnd.Day);
            var          listPur   = manager.AllPurchases().Where(p => p.CarID.HasValue && p.CarID.Value == CarID && p.PurchasesStatus.HasValue && p.PurchasesStatus.Value == 1 && p.PurchaseDate.HasValue && p.ReturnDate.HasValue && ((p.PurchaseDate.Value <= DateStart && p.ReturnDate.Value >= DateStart) || (p.PurchaseDate.Value <= DateEnd && DateEnd <= p.ReturnDate.Value))).FirstOrDefault();

            if (listPur != null)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 6
0
        public ActionResult MyBusket()
        {
            //var deals = Session[DEALS_IN_THE_BUSKET] as List<PurchaseView>;
            ManagerQuery manager = new ManagerQuery();

            if (User == null || string.IsNullOrEmpty(User.Identity.Name))
            {
                return(RedirectToAction("Login", "Home"));
            }
            var UserID  = manager.GetAllUsers().Where(p => p.UserName == User.Identity.Name).Select(p => p.ID).FirstOrDefault();
            var listPur = manager.AllPurchases().Where(p => p.UserId == UserID && (!p.PurchasesStatus.HasValue || p.PurchasesStatus.Value == 0)).ToList();
            List <PurchaseView> deals = new List <PurchaseView>();

            if (listPur.Count > 0)
            {
                foreach (var pur in listPur)
                {
                    var purView = new PurchaseView(pur);
                    purView.Availlability = (pur.CarID.HasValue && pur.PurchaseDate.HasValue && pur.ReturnDate.HasValue) ? CheckCarAvailability(pur.PurchaseDate.Value, pur.ReturnDate.Value, pur.CarID.Value) : false;
                    deals.Add(purView);
                }
            }
            return(View(deals));
        }