Пример #1
0
        public ActionResult Index(RequestsIndexViewModel vm)
        {
            // Get the logged in Site ID from the session
            int?SiteID = Session["SiteID"] as int?;

            // if there is none, redirect to the login page
            if (!SiteID.HasValue)
            {
                return(RedirectToAction("Login", "Account"));
            }

            ModelState.Remove("Items");

            vm.SortByChoiceOptions = GetSortByChoiceOptions();
            vm.SortByOrderOptions  = GetSortByOrderOptions();

            // get requests
            string sql = String.Format("SELECT r.RequestID, i.ItemName, i.Category1, i.Category2, i.StorageType, r.RequestedQuantity, r.Status, r.FulfilledQuantity, i.ItemID " +
                                       "FROM request r " +
                                       "INNER JOIN item i on i.ItemID = r.ItemID " +
                                       "WHERE i.SiteID = {0} AND r.Status='Pending' " +
                                       "ORDER BY {1} {2} ;", SiteID.Value.ToString(), vm.SortByChoice, vm.SortByOrder);

            vm.Requests = GetRequests(sql);

            return(View(vm));
        }
Пример #2
0
        // GET: User/Request
        public ActionResult Index()
        {
            var LoggedUser = db.Users.Where(u => u.Email.Equals(User.Identity.Name)).First();
            var requests   = db.Requests.Where(x => !x.Deleted && (x.CreatedBy.Id == LoggedUser.Id || x.ApproverLevel1.Id == LoggedUser.Id || x.ApproverLevel2.Id == LoggedUser.Id || x.ApproverLevel3.Id == LoggedUser.Id || x.ApproverLevel4.Id == LoggedUser.Id)).ToList();
            RequestsIndexViewModel model = new RequestsIndexViewModel
            {
                Accepted = requests.Where(x => x.StatusLevel4 == 0).OrderByDescending(x => x.Date).ToList(),
                Level4   = requests.Where(x => x.StatusLevel4 != 0).OrderByDescending(x => x.Date).ToList(),
                Level3   = requests.Where(x => x.StatusLevel3 != 0).OrderByDescending(x => x.Date).ToList(),
                Level2   = requests.Where(x => x.StatusLevel2 != 0).OrderByDescending(x => x.Date).ToList(),
                Level1   = requests.Where(x => x.StatusLevel1 != 0).OrderByDescending(x => x.Date).ToList()
            };

            return(View(model));
        }
Пример #3
0
        // GET: Site
        public ActionResult Index()
        {
            // Get the logged in Site ID from the session
            int?SiteID = Session["SiteID"] as int?;

            // if there is none, redirect to the login page
            if (!SiteID.HasValue)
            {
                return(RedirectToAction("Login", "Account"));
            }

            // find out if the current Site has a Food Bank or not
            var hasFoodBank = Int32.Parse(SqlHelper.ExecuteScalar("SELECT COUNT(*) FROM foodbank WHERE SiteID = " + SiteID.Value).ToString()) > 0;

            if (!hasFoodBank)
            {
                throw new Exception("Access Denied to Outstanding Requests Report. Site ID " + SiteID.Value.ToString() + " does not have a food bank.");
            }

            RequestsIndexViewModel vm = new RequestsIndexViewModel
            {
                SiteID              = SiteID.Value,
                SiteName            = Session["SiteName"].ToString(),
                SortByChoiceOptions = GetSortByChoiceOptions(),
                SortByOrderOptions  = GetSortByOrderOptions(),
                SortByChoice        = GetSortByChoiceOptions().First().Value,
                SortByOrder         = GetSortByOrderOptions().First().Value
            };

            // get the pending requests and all related data needed for this view
            string sql = String.Format("SELECT r.RequestID, i.ItemName, i.Category1, i.Category2, i.StorageType, r.RequestedQuantity, r.Status, r.FulfilledQuantity, i.ItemID " +
                                       "FROM request r " +
                                       "INNER JOIN item i on i.ItemID = r.ItemID " +
                                       "WHERE i.SiteID = {0} AND r.Status='Pending' " +
                                       "ORDER BY {1} {2} ;", SiteID.Value.ToString(), vm.SortByChoice, vm.SortByOrder);

            vm.Requests = GetRequests(sql);

            return(View(vm));
        }
        /// <summary>
        /// Show default metrics
        /// </summary>
        public IActionResult Index()
        {
            string sessionId = this.cookie.Get("TelemetrySession");

            if (string.IsNullOrEmpty(sessionId))
            {
                return(RedirectToAction("Login", "Account"));
            }
            else
            {
                GetUserByCookieResponse reportUserByCookie = this.authenticationService.GetUserByWebCookie(sessionId);
                if (reportUserByCookie.Success == true)
                {
                    var viewModel = new RequestsIndexViewModel(telemetryRetrievalService);
                    return(View(viewModel));
                }
                else
                {
                    return(RedirectToAction("Login", "Account"));
                }
            }
        }
Пример #5
0
        // GET: User/Request
        public ActionResult Index()
        {
            var            LoggedUser = db.Users.Where(u => u.Email.Equals(User.Identity.Name)).First();
            List <Request> requests;

            if (LoggedUser.UserCategory == UserCategory.ADM || LoggedUser.UserCategory == UserCategory.DM || LoggedUser.UserCategory == UserCategory.SA)
            {
                requests = db.Requests.Include("CreatedBy").Where(x => !x.Deleted && x.Active).ToList();
            }
            else
            {
                requests = db.Requests.Include("CreatedBy").Where(x => !x.Deleted && x.Active && (x.CreatedBy.Id == LoggedUser.Id || x.ApproverLevel1.Id == LoggedUser.Id || x.ApproverLevel2.Id == LoggedUser.Id || x.ApproverLevel3.Id == LoggedUser.Id || x.ApproverLevel4.Id == LoggedUser.Id)).ToList();
            }
            RequestsIndexViewModel model = new RequestsIndexViewModel
            {
                Accepted = requests.Where(x => x.CurrentLevel == 5).OrderByDescending(x => x.Date).ToList(),
                Level4   = requests.Where(x => x.CurrentLevel == 4).OrderByDescending(x => x.Date).ToList(),
                Level3   = requests.Where(x => x.CurrentLevel == 3).OrderByDescending(x => x.Date).ToList(),
                Level2   = requests.Where(x => x.CurrentLevel == 2).OrderByDescending(x => x.Date).ToList(),
                Level1   = requests.Where(x => x.CurrentLevel == 1).OrderByDescending(x => x.Date).ToList()
            };

            return(View(model));
        }