Esempio n. 1
0
        public PartialViewResult FilterRequests(string rDate)
        {
            IndexList indexList = new IndexList();
            DateTime requestDate;
            if (DateTime.TryParseExact(rDate, "dd.MM.yyyy", null, System.Globalization.DateTimeStyles.None, out requestDate))
            {
                if (User.IsInRole("LAN\\TR_Managers") || AccountManager.IsApprover(User.Identity.Name).Item2 || User.IsInRole("LAN\\TR_Viewers"))
                {
                    var model = _db.Requests
                        .Where(r => ((r.IsDeleted != true || r.IsDeleted == null) && r.RequestDate == requestDate))
                        .OrderByDescending(r => r.PublishDate)
                        .ToList();
                    foreach (var r in model)
                    {
                        r.DetailsLink = RequestType.GetDetailsLink(r);
                        r.DetailsButton = RequestType.GetDetailsButton(r);
                        r.RequestTypeLabel = RequestType.GetRequestTypeLabel(r);
                    }
                    indexList.Requests = model;
                    indexList.TotalRows = model.Count;
                    indexList.RowPerPage = model.Count;
                    return PartialView("_Table", indexList);
                }
                else
                {
                    var model = _db.Requests
                        .Where(r => ((r.IsDeleted != true || r.IsDeleted == null) && r.UserLogin == User.Identity.Name && r.RequestDate == requestDate))
                        .OrderByDescending(r => r.PublishDate)
                        .ToList();
                    foreach (var r in model)
                    {
                        r.DetailsLink = RequestType.GetDetailsLink(r);
                        r.DetailsButton = RequestType.GetDetailsButton(r);
                        r.RequestTypeLabel = RequestType.GetRequestTypeLabel(r);
                    }
                    indexList.Requests = model;
                    indexList.TotalRows = model.Count;
                    indexList.RowPerPage = model.Count;
                    return PartialView("_Table", indexList);
                }
            }
            else
            {
                if (User.IsInRole("LAN\\TR_Managers") || AccountManager.IsApprover(User.Identity.Name).Item2 || User.IsInRole("LAN\\TR_Viewers"))
                {
                    var model = _db.Requests
                        .Where(r => (r.IsDeleted != true || r.IsDeleted == null))
                        .OrderByDescending(r => r.PublishDate)
                        .ToList();

                    foreach (var r in model)
                    {
                        r.DetailsLink = RequestType.GetDetailsLink(r);
                        r.DetailsButton = RequestType.GetDetailsButton(r);
                        r.RequestTypeLabel = RequestType.GetRequestTypeLabel(r);
                    }
                    indexList.Requests = model;
                    indexList.TotalRows = model.Count;
                    indexList.RowPerPage = model.Count;
                    return PartialView("_Table", indexList);
                }
                else
                {
                    var model = _db.Requests
                        .Where(r => ((r.IsDeleted != true || r.IsDeleted == null) && r.UserLogin == User.Identity.Name))
                        .OrderByDescending(r => r.PublishDate)
                        .ToList();

                    foreach (var r in model)
                    {
                        r.DetailsLink = RequestType.GetDetailsLink(r);
                        r.DetailsButton = RequestType.GetDetailsButton(r);
                        r.RequestTypeLabel = RequestType.GetRequestTypeLabel(r);
                    }
                    indexList.Requests = model;
                    indexList.TotalRows = model.Count;
                    indexList.RowPerPage = model.Count;
                    return PartialView("_Table", indexList);
                }
            }
        }
Esempio n. 2
0
        public ActionResult RequestsToApprove(int id)
        {
            IndexList indexList = new IndexList();
               if (!_db.RequestApprovers.Any( a => a.EmployeeId == id) && !User.IsInRole("LAN\\TR_Admins"))
               {
              ViewBag.BackController = "Home";
              return View("Denied");
               }

               var model = _db.Requests
                    .Where(r => ((r.IsDeleted != true || r.IsDeleted == null) && r.ApproverEmployeeId == id && r.Status == 0))
                    .OrderByDescending(r => r.PublishDate)
                    .ToList();

               foreach (var r in model)
               {
               r.DetailsLink = RequestType.GetDetailsLink(r);
               r.DetailsButton = RequestType.GetDetailsButton(r);
               r.RequestTypeLabel = RequestType.GetRequestTypeLabel(r);
               }
               indexList.Requests = model;
               indexList.TotalRows = model.Count;
               indexList.RowPerPage = model.Count;
               return View(indexList);
        }
Esempio n. 3
0
        public PartialViewResult ShowNewRequestsToApprover(int id)
        {
            IndexList indexList = new IndexList();

            var model = _db.Requests
                    .Where(r => ((r.IsDeleted != true || r.IsDeleted == null) && r.ApproverEmployeeId == id && r.Status == 0))
                    .OrderByDescending(r => r.PublishDate)
                    .ToList();

            foreach (var r in model)
            {
                r.DetailsLink = RequestType.GetDetailsLink(r);
                r.DetailsButton = RequestType.GetDetailsButton(r);
                r.RequestTypeLabel = RequestType.GetRequestTypeLabel(r);
            }
            ViewBag.Message = "Показаны неподписанные";
            ViewBag.LinkText = "Показать подписанные и неподписанные";
            ViewBag.ActionName = "ShowAllRequestsToApprover";

            indexList.Requests = model;
            indexList.TotalRows = model.Count;
            indexList.RowPerPage = model.Count;
            return PartialView("_SignRequests", indexList);
        }
Esempio n. 4
0
        public ActionResult Index(int? page)
        {
            var indexList = new IndexList();
            indexList.RowPerPage = 30;
            int skip = 0;
            if (page.HasValue)
            {
                skip = indexList.RowPerPage * ((Int32)page - 1);
            }

            //Общий список заявок, доступен TR_Managers, Viewers и Тем, кто имеет право подписи
            if (User.IsInRole("LAN\\TR_Managers") || AccountManager.IsApprover(User.Identity.Name).Item2 || User.IsInRole("LAN\\TR_Viewers"))
            {
                var model = _db.Requests
                    .Where(r => (r.IsDeleted != true || r.IsDeleted == null))
                    .OrderByDescending(r => r.PublishDate)
                    .Skip(skip)
                    .Take(30)
                    .ToList();

                foreach (var r in model)
                {
                    r.DetailsLink = RequestType.GetDetailsLink(r);
                    r.DetailsButton = RequestType.GetDetailsButton(r);
                    r.RequestTypeLabel = RequestType.GetRequestTypeLabel(r);
                }
                indexList.Requests = model;
                indexList.TotalRows = _db.Requests.Count(r => (r.IsDeleted != true || r.IsDeleted == null));
                return View(indexList);
            }
            else //Список заявок конкретного пользователя
            {
                var model = _db.Requests
                    .Where(r => ((r.IsDeleted != true || r.IsDeleted == null) && r.UserLogin == User.Identity.Name))
                    .OrderByDescending(r => r.PublishDate)
                    .Skip(skip)
                    .Take(30)
                    .ToList();

                foreach (var r in model)
                {
                    r.DetailsLink = RequestType.GetDetailsLink(r);
                    r.DetailsButton = RequestType.GetDetailsButton(r);
                    r.RequestTypeLabel = RequestType.GetRequestTypeLabel(r);
                }
                indexList.Requests = model;
                indexList.TotalRows = _db.Requests.Count(r => ((r.IsDeleted != true || r.IsDeleted == null) && r.UserLogin == User.Identity.Name));
                return View(indexList);
            }
        }