public ActionResult MealRecord()
        {
            User currentUser = SetSession.GetCurrentUser();

            if (currentUser == null)
            {
                return(RedirectToAction("index", "home"));
            }
            else if (currentUser.AccountType == "u")
            {
                return(RedirectToAction("index", "homepage"));
            }


            //User currentUser = SetSession.GetCurrentUser();

            if (currentUser == null)
            {
                return(RedirectToAction("index", "home"));
            }
            else if (currentUser.AccountType == "u")
            {
                return(RedirectToAction("index", "homepage"));
            }
            return(View());
        }
        public ActionResult Index(User user)
        {
            if (String.IsNullOrEmpty(user.Name) ||
                String.IsNullOrEmpty(user.Password) ||
                String.IsNullOrEmpty(user.Status))
            {
                ViewBag.msg = "Input Error";
                return(View());
            }

            User currentUser = SetSession.GetCurrentUser();

            user.Id    = currentUser.Id;
            user.Email = currentUser.Email;

            UserManager userManager = new UserManager();

            ViewBag.msg = userManager.UpdateUser(user);

            SetSession.SetUser(currentUser.Email);



            return(View());
        }
        public async Task <ActionResult> Login(LoginViewModel lvm)
        {
            var sb = new StringBuilder();
            var fa = FirebaseConnection.FirebaseAuthentication();

            try
            {
                var userAuth = await fa.SignInWithEmailAndPasswordAsync(lvm.userName, lvm.password);

                var firebase    = FirebaseConnection.FirebaseDatabase();
                var userDetails = await firebase.Child("adminUserRegistration").Child(userAuth.User.LocalId).OnceAsync <GetRegistrationViewModel>();

                foreach (var ud in userDetails)
                {
                    SetSession.SetUserSession(userAuth.User.LocalId, ud.Object.designation, sb.Append(ud.Object.firstName).Append(" ").Append(ud.Object.lastName).ToString());
                }
                return(RedirectToAction("Index", "Admin"));
            }
            catch (Exception userAuthException)
            {
                var userError = userAuthException.GetType().GetProperty("Reason").GetValue(userAuthException, null);
                ModelState.AddModelError("error", userError.ToString());
                return(View());
            }
        }
        public ActionResult Index(string email, int?addbalance)
        {
            UserManager userManager = new UserManager();

            User userToAdd = userManager.GetUserByEmail(email);

            if (addbalance < UserManager.minimumBalance || addbalance == null)
            {
                ViewBag.msg = "Wrong Input or Lower Balance";
                return(View());
            }

            if (userToAdd == null)
            {
                ViewBag.msg = "Email Not Found !!!";
                return(View());
            }

            Transaction transaction = new Transaction();

            transaction.Amount           = Convert.ToDouble(addbalance);
            transaction.OperatedToUserId = userToAdd.Id;
            transaction.OperatedByUserId = SetSession.GetCurrentUser().Id;
            transaction.TransactionType  = Transaction.add;


            ViewBag.msg = userManager.AddBalanceByTransaction(transaction);

            return(View());
        }
        public ActionResult Index(string email, string password)
        {
            if (String.IsNullOrEmpty(password) || String.IsNullOrEmpty(email))
            {
                ViewBag.msg = "Empty input";
                return(View());
            }

            UserManager userManager = new UserManager();

            User userToLogIn = userManager.LogIn(email, password);

            if (userToLogIn != null)
            {
                ViewBag.msg = "Log In Successfully";
                //ViewBag.user = userToLogIn;
                SetSession.SetUser(userToLogIn);
                return(RedirectToAction("index", "HomePage"));
            }
            else
            {
                ViewBag.msg = "Wrong Password or E-Mail";
            }

            return(View());
        }
Beispiel #6
0
 // GET: HomePage
 public ActionResult Index()
 {
     if (!SetSession.IsUserSessionSet())
     {
         return(RedirectToAction(AccessControl.defaultAction, AccessControl.defaultController));
     }
     return(View());
 }
Beispiel #7
0
 // GET: LogOut
 public ActionResult Index()
 {
     if (SetSession.IsUserSessionSet())
     {
         SetSession.RemoveUser();
     }
     return(RedirectToAction("index", "home"));
 }
 public ActionResult Index()
 {
     if (SetSession.IsUserSessionSet())
     {
         return(RedirectToAction("index", "HomePage"));
     }
     return(View());
 }
Beispiel #9
0
        // GET: ProfileInfo
        public ActionResult Index()
        {
            User currentUser = SetSession.GetCurrentUser();

            if (currentUser == null)
            {
                return(RedirectToAction("Index", "home"));
            }
            return(View());
        }
Beispiel #10
0
        public ActionResult Index(double amount)
        {
            ExpenseManager expenseManager = new ExpenseManager();
            User           currentUser    = SetSession.GetCurrentUser();
            Expense        currentExpense = new Expense();

            currentExpense.UserId = currentUser.Id;
            currentExpense.Amount = amount;

            ViewBag.msg = expenseManager.AddDailyExpenses(currentExpense);

            return(View());
        }
Beispiel #11
0
        /*http://localhost:49823/ProfileInfo/Index?userId=nothing*/

        public ActionResult Index(int?userId)
        {
            User currentUser = SetSession.GetCurrentUser();

            if (currentUser == null)
            {
                return(RedirectToAction("Index", "home"));
            }
            UserGateway userGateway = new UserGateway();

            ViewBag.usersProfile = userGateway.GetUserByUserId(Convert.ToInt32(userId));

            return(View());
        }
        // GET: NewOrder
        public ActionResult Index()
        {
            User currentUser = SetSession.GetCurrentUser();

            if (currentUser == null)
            {
                return(RedirectToAction("Index", "home"));
            }

            OrderManager orderManager = new OrderManager();

            string today = DateTime.Now.ToString("yyyy-MM-dd");

            ViewBag.orderToday = orderManager.GetOrderByUseIdAndDate(currentUser.Id, today);

            return(View());
        }
Beispiel #13
0
        public ActionResult Add(double amount)
        {
            if (amount <= 0)
            {
                ViewBag.msg = "Wrong Input or Lower Amount";
                return(View());
            }
            ExpenseManager expenseManager = new ExpenseManager();
            User           currentUser    = SetSession.GetCurrentUser();
            Expense        currentExpense = new Expense();

            currentExpense.UserId = currentUser.Id;
            currentExpense.Amount = amount;

            ViewBag.msg = expenseManager.AddDailyExpenses(currentExpense);

            return(View());
        }
Beispiel #14
0
        public ActionResult Index(int?pricepermeal)
        {
            int pricePermealValidate = Convert.ToInt32(pricepermeal);

            if (pricePermealValidate <= 0)
            {
                return(View());
            }
            PriceOfMealManager priceOfMealManager = new PriceOfMealManager();
            PriceOfMeal        priceOfMeal        = new PriceOfMeal();
            User currentUser = SetSession.GetCurrentUser();

            priceOfMeal.PricePerMeal = pricePermealValidate;
            priceOfMeal.UserId       = currentUser.Id;

            ViewBag.msg = priceOfMealManager.SetPirce(priceOfMeal);
            return(View());
        }
        public ActionResult Index(Time time)
        {
            //Validation start
            if (String.IsNullOrEmpty(time.Time1Start) || String.IsNullOrEmpty(time.Time1End) ||
                String.IsNullOrEmpty(time.Time2Start) || String.IsNullOrEmpty(time.Time2End) ||
                String.IsNullOrEmpty(time.Time3Start) || String.IsNullOrEmpty(time.Time3End))
            {
                ViewBag.msg = "Input Error";
                return(View());
            }

            DateTime timeTestString;


            bool time1startTest = !DateTime.TryParse(time.Time1Start, out timeTestString);
            bool time2startTest = !DateTime.TryParse(time.Time2Start, out timeTestString);
            bool time3startTest = !DateTime.TryParse(time.Time3Start, out timeTestString);

            bool time1EndTest = !DateTime.TryParse(time.Time1End, out timeTestString);
            bool time2EndTest = !DateTime.TryParse(time.Time2End, out timeTestString);
            bool time3EndTest = !DateTime.TryParse(time.Time3End, out timeTestString);


            if (time1startTest || time2startTest || time3startTest ||
                time1EndTest || time2EndTest || time3EndTest)
            {
                ViewBag.msg = "Wrong Time Format";
                return(View());
            }

            //Validation end

            TimeManager timeManager = new TimeManager();
            User        currentUser = SetSession.GetCurrentUser();

            time.UserId        = currentUser.Id;
            time.DateOfSetTime = DateTime.Now.ToString("yyyy-MM-dd");
            time.TimeOfSetTime = DateTime.Now.ToString("h:mm tt");

            ViewBag.msg = timeManager.SetTime(time);

            return(View());
        }
Beispiel #16
0
        // GET: AllUserList
        public ActionResult Index()
        {
            User currentUser = SetSession.GetCurrentUser();

            if (currentUser == null)
            {
                return(RedirectToAction("index", "home"));
            }
            else if (currentUser.AccountType == "u")
            {
                return(RedirectToAction("index", "homepage"));
            }

            UserManager userManager = new UserManager();

            ViewBag.allUserList = userManager.GetAllUser();

            return(View());
        }
Beispiel #17
0
        // GET: CalculateForDay
        public ActionResult Index()
        {
            User currentUser = SetSession.GetCurrentUser();

            if (currentUser == null)
            {
                return(RedirectToAction("index", "home"));
            }
            else if (currentUser.AccountType == "u")
            {
                return(RedirectToAction("index", "homepage"));
            }


            CalculationManager calculationManager = new CalculationManager();

            calculationManager.CalculateForMonthDay();

            return(View());
        }
Beispiel #18
0
        // GET: ShowPrice
        public ActionResult Index()
        {
            User currentUser = SetSession.GetCurrentUser();

            if (currentUser == null)
            {
                return(RedirectToAction("index", "home"));
            }
            else if (currentUser.AccountType == "u")
            {
                return(RedirectToAction("index", "homepage"));
            }


            PriceOfMealManager priceOfMealManager = new PriceOfMealManager();

            ViewBag.price = priceOfMealManager.GetLastPrice();

            return(View());
        }
Beispiel #19
0
        public void CalculateForMonth()
        {
            DateTime currentDate    = BdTime.GetCurrentDate();
            DateTime oneMonthBefore = currentDate.AddMonths(-1);


            MonthCheckManager monthCheckManager = new MonthCheckManager();
            OrderManager      orderManager      = new OrderManager();
            ExpenseManager    expenseManager    = new ExpenseManager();


            if (monthCheckManager.GetMonthCheckByMonthYear(oneMonthBefore.Month, oneMonthBefore.Year) == null)
            {
                TransactionManager transactionManager = new TransactionManager();


                User currentUser = SetSession.GetCurrentUser();

                List <Order> totalMealOfOrderList = orderManager.TotalMealForMonthByUserList(oneMonthBefore.Month, oneMonthBefore.Year);

                List <Transaction> listOfTransaction =
                    transactionManager.MakeTransactionListByTotalMealOrderAndMonth
                        (totalMealOfOrderList, currentUser.Id, oneMonthBefore.Month, oneMonthBefore.Year);

                transactionManager.MakeTransactionFromTransactionListForTotalCalculation(listOfTransaction);


                double averageMealPriceOfMonth = expenseManager.GetAverageMealPriceOfMonth(oneMonthBefore.Month, oneMonthBefore.Year);


                orderManager.AddMealPriceForAllOrderByMonth(oneMonthBefore.Month, oneMonthBefore.Year, averageMealPriceOfMonth);


                monthCheckManager.AddCheckForMonthYear(oneMonthBefore.Month, oneMonthBefore.Year);
            }
        }
        public ActionResult Index(double?mealOne, double?mealTwo, double?mealThree)
        {
            if (mealOne < 0 || mealTwo < 0 || mealThree < 0)
            {
                return(View());
            }


            OrderManager orderManager = new OrderManager();
            TimeManager  timeManager  = new TimeManager();

            User currentUser = SetSession.GetCurrentUser();

            Order currentOrder = new Order();

            currentOrder.UserId = currentUser.Id;

            currentOrder.Meal1 = Convert.ToDouble(mealOne);
            currentOrder.Meal2 = Convert.ToDouble(mealTwo);
            currentOrder.Meal3 = Convert.ToDouble(mealThree);



            currentOrder.Date = DateTime.Today.ToString("yyyy-MM-dd");

            Order orderFoundBySearch = orderManager.GetOrder(currentOrder);

            Time lastTime = timeManager.GetLastTime();

            DateTime timeNow = DateTime.Parse(DateTime.Now.ToString("hh:mm"));

            DateTime meal1EndTime = DateTime.Parse(lastTime.Time1End);
            DateTime meal2EndTime = DateTime.Parse(lastTime.Time2End);
            DateTime meal3EndTime = DateTime.Parse(lastTime.Time3End);

            if (orderFoundBySearch != null)
            {
                if (timeNow >= meal1EndTime)
                {
                    currentOrder.Meal1 = orderFoundBySearch.Meal1;
                }

                if (timeNow >= meal2EndTime)
                {
                    currentOrder.Meal2 = orderFoundBySearch.Meal2;
                }

                if (timeNow >= meal3EndTime)
                {
                    currentOrder.Meal3 = orderFoundBySearch.Meal3;
                }


                ViewBag.msg = orderManager.UpdateOrder(currentOrder);
            }
            else
            {
                if (timeNow >= meal1EndTime)
                {
                    currentOrder.Meal1 = 1;
                }

                if (timeNow >= meal2EndTime)
                {
                    currentOrder.Meal2 = 1;
                }

                if (timeNow >= meal3EndTime)
                {
                    currentOrder.Meal3 = 1;
                }

                ViewBag.msg = orderManager.PutOrder(currentOrder);
            }

            ViewBag.orderToday = orderManager.GetOrderByUseIdAndDate(currentUser.Id, DateTime.Now.ToString("yyyy-MM-dd"));

            return(View());
        }