示例#1
0
        public IActionResult GetTrayDetails(int tid)
        {
            TrayModel       model = new TrayModel(_db);
            ApplicationUser user  = HttpContext.Session.Get <ApplicationUser>(SessionVariables.User);

            return(Ok(model.GetTrayDetails(tid, user.Id)));
        }
示例#2
0
        // Add the tray, pass the session variable info to the db
        public ActionResult AddTray()
        {
            TrayModel model      = new TrayModel(_db);
            int       retVal     = -1;
            string    retMessage = "";

            try
            {
                Dictionary <string, object> trayItems = HttpContext.Session.Get <Dictionary <string,
                                                                                             object> >(SessionVariables.Tray);
                retVal = model.AddTray(trayItems,
                                       HttpContext.Session.Get <ApplicationUser>(SessionVariables.User));
                if (retVal > 0) // Tray Added
                {
                    retMessage = "Tray " + retVal + " Created!";
                }
                else // problem
                {
                    retMessage = "Tray not added, try again later";
                }
            }
            catch (Exception ex) // big problem
            {
                retMessage = "Tray was not created, try again later! - " + ex.Message;
            }
            HttpContext.Session.Remove(SessionVariables.Tray); // clear out current tray oncepersisted
            HttpContext.Session.SetString(SessionVariables.Message, retMessage);
            return(Redirect("/Home"));
        }
示例#3
0
        public IActionResult GetTrays()
        {
            ApplicationUser user  = HttpContext.Session.Get <ApplicationUser>(SessionVariables.User);
            TrayModel       model = new TrayModel(_db);

            return(Ok(model.GetAll(user)));
        }