Exemple #1
0
 public ActionResult CarList()
 {
     CarListViewModel carList = new CarListViewModel();
     carList.CarList = new List<CarViewModel>();
     IEnumerable<cars> cars = dataManager.Cars.GetCars();
     foreach (cars c in cars)
     {
         carList.CarList.Add(new CarViewModel
         {
             Id = c.CarId,
             CarNumber = c.CarNumber,
             StateNumber = c.StateNumber,
             ChassisNumber = c.ChassisNumber,
             DateRelease = c.DateRelease,
             BranchListId = c.BranchListId
         });
     }
     return View(carList);
 }
Exemple #2
0
        public ActionResult AllDocuments()
        {
            int orgId = 0;
            DateTime? Ds = null;
            DateTime? Dp = null;
            if (Request.Cookies["DocCookie"] != null)
            {
                if (Request.Cookies["DocCookie"]["org"] != "")
                {
                    orgId = Convert.ToInt32(Request.Cookies["DocCookie"]["org"]);
                }
                if (Request.Cookies["DocCookie"]["dateS"] != "")
                {
                    Ds = Convert.ToDateTime(Request.Cookies["DocCookie"]["dateS"]);
                }
                if (Request.Cookies["DocCookie"]["datePo"] != "")
                {
                    Dp = Convert.ToDateTime(Request.Cookies["DocCookie"]["datePo"]);
                }
            }
            ViewBag.DropDownListOrg = (orgId != 0) ? new SelectList(dataManager.Organizations.GetOrgList(), "id", "Name", orgId) : new SelectList(dataManager.Organizations.GetOrgList(), "id", "Name", null);
            ViewBag.DocTypes = dataManager.DocumentTypes.GetDocumentTypes();
            IEnumerable<cars> cars = (orgId != 0) ? dataManager.Cars.GetCars().Where(x => x.BranchListId == orgId) : dataManager.Cars.GetCars();
            if (cars.Count() != 0)
            {
                CarListViewModel carList = new CarListViewModel();
                if (Ds != null && Dp != null)
                {
                    carList.DateS = Ds;
                    carList.DatePo = Dp;
                }
                carList.CarList = new List<CarViewModel>();
                foreach (cars c in cars)
                {
                    int colorPrior = 0;
                    int maxColorProir = 0;
                    IEnumerable<documents> docs = (Ds != null && Dp != null) ? dataManager.Documents.GetDocumentsByCar(c.CarId).Where(x => x.datePo >= Ds && x.datePo <= Dp).OrderBy(x => x.datePo) : dataManager.Documents.GetDocumentsByCar(c.CarId).OrderBy(x => x.datePo);

                    CarViewModel car = new CarViewModel();
                    car.Id = c.CarId;
                    car.CarNumber = c.CarNumber;
                    car.StateNumber = c.StateNumber;
                    if (c.BranchListId != null)
                    {
                        car.BranchName = c.organizationLists.name;
                    }
                    IEnumerable<documentTypes> docTypes = dataManager.DocumentTypes.GetDocumentTypes();
                    if (docTypes.Count() != 0)
                    {
                        car.DocList = new List<DocumentViewModel>();
                        foreach (documentTypes dt in docTypes)
                        {
                            DocumentViewModel d = new DocumentViewModel();
                            foreach (documents doc in docs)
                            {
                                if (doc.docTypeID == dt.id)
                                {
                                    if (doc.datePo != null)
                                    {
                                        DateTime shortDate = Convert.ToDateTime(doc.datePo);
                                        shortDate.ToShortDateString();
                                        d.DocName = shortDate.ToShortDateString();
                                        d.DatePo = shortDate;
                                        int days = ((TimeSpan)(doc.datePo - DateTime.Today)).Days;
                                        if (days <= 0)
                                        {
                                            d.color = "#ff0000";
                                            colorPrior = 3;
                                        }
                                        if (days > 0 && days <= dt.alarm2)
                                        {
                                            d.color = "#ffd800";
                                            colorPrior = 2;
                                        }
                                        if (days > dt.alarm2 && days <= dt.alarm1)
                                        {
                                            d.color = "#00ff21";
                                            colorPrior = 1;
                                        }
                                    }
                                    else
                                    {
                                        d.DocName = "Есть";
                                    }
                                }
                                if (dt.orgID != c.BranchListId && dt.orgID != null)
                                {
                                    d.DocName = "Не нужно";
                                }
                            }
                            car.DocList.Add(d);
                            if (maxColorProir < colorPrior)
                                maxColorProir = colorPrior;
                        }
                    }
                    if (maxColorProir == 3) car.color = "#ff0000";
                    if (maxColorProir == 2) car.color = "#ffd800";
                    if (maxColorProir == 1) car.color = "#00ff21";
                    carList.CarList.Add(car);
                }
                return View(carList);
            }
            return View();
        }
Exemple #3
0
        public ActionResult AllDocuments(CarListViewModel model)
        {
            HttpCookie mycook = new HttpCookie("DocCookie");

            mycook["org"] = model.OrgID.ToString();
            mycook["dateS"] = model.DateS.ToString();
            mycook["datePo"] = model.DatePo.ToString();
            Response.Cookies.Add(mycook);
            Response.Cookies["DocCookie"].Expires = DateTime.Now.AddDays(10);

            return RedirectToAction("AllDocuments", "Home");
        }