예제 #1
0
        public ActionResult Sales()
        {
            string title = "Sales";

            Load(title);

            SqlStoredProcedures sqlSP = new SqlStoredProcedures();
            var shifts = sqlSP.StoreGetCurrentShifts();


            if (user == null || !user.HasPolicy(new Policy("Store.Sales.Access")) || !shifts.ContainsKey(user.GetUserID()))
            {
                return(RedirectToAction("Home", "Main"));
            }

            foreach (KeyValuePair <int, char> shift in shifts)
            {
                if (shift.Key == user.GetUserID())
                {
                    ViewBag.store = shift.Value;
                    break;
                }
            }

            ViewBag.categories = Product.GetProductCategories();
            ViewBag.products   = Product.GetAllProducts();
            return(View(title));
        }
예제 #2
0
        public void Login(int userID, string sessionToken, char store)
        {
            //Valid User and Is Manager
            User user = new User(userID);

            user.SignInWithSessionToken(sessionToken, GetIPAddress());
            if (user.GetSessionToken() == null || !user.HasPolicy(new Policy("Store.Sales.Access")))
            {
                return;
            }

            //Time between 9am to 3pm
            //TimeSpan time = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.UtcNow, "Pacific Standard Time").TimeOfDay;
            //if (time <= startTime || time >= endTime)
            //{
            //    return;
            //}


            //Working Today And In the Correct Store
            SqlStoredProcedures sqlSP = new SqlStoredProcedures();
            var shift = sqlSP.StoreGetCurrentShifts();

            if (!shift.ContainsKey(userID) && Char.ToLower(shift[userID]) != Char.ToLower(store))
            {
                return;
            }

            //Add User
            onlineUsers.Add(Context.ConnectionId, userID);
            if (!uniqueOnlineUsers.Contains(userID))
            {
                uniqueOnlineUsers.Add(userID);
            }
            userStoreDic.Add(Context.ConnectionId, Char.ToLower(store));
            Clients.Client(Context.ConnectionId).LoginSuccess();
            UpdateAllSaleCounts();
        }