Ejemplo n.º 1
0
        public ActionResult Page2(ViewModels.vmPage2 vmPage2, string GUID)
        {
            List <string> errMsgList = new List <string>();

            string buttonValue = Request.Form["submit"];

            //INPUTS AND OUTPUTS
            //1. ModelState Valid and No Redirect       - Save and no redirect
            //2. ModelState Valid and Redirect.         - Save and redirect
            //3. ModelState Invalid and No Redirect     -No save and re-display
            //4. ModelState Invalid and Redirect        -No save are redirect

            if (ModelState.IsValid)
            {
                Application application = db.Applications
                                          .Where(e => e.GUID == GUID)
                                          .FirstOrDefault();
                //Set the relevant properties
                application.StallType   = vmPage2.StallType;
                application.FoodDetails = vmPage2.FoodDetails;
                try
                {
                    db.SaveChanges();
                }
                catch (DbEntityValidationException ex)
                {
                    if (!buttonValue.ToLower().Contains("prev"))
                    {
                        return(View("_DbEntityValidationException", ex));
                    }
                }
                catch
                {
                    //Do nothing
                }


                if (buttonValue.ToLower().Contains("prev"))
                {
                    return(RedirectToAction("Page1", new { GUID = GUID }));
                }
                return(RedirectToAction("Page3", new { GUID = GUID }));
            }
            else
            {
                //Model state is not valid

                if (buttonValue.ToLower().Contains("prev"))
                {
                    return(RedirectToAction("Page1", new { GUID = GUID }));
                }
                return(View(vmPage2));
            }
        }
Ejemplo n.º 2
0
        //GET:  Page2
        public ActionResult Page2(string GUID)
        {
            ViewModels.vmPage2 vmPage2 =
                db.Applications.Where(e => e.GUID == GUID)
                .Select(e => new ViewModels.vmPage2()
            {
                Id          = e.Id,
                FoodDetails = e.FoodDetails,
                StallType   = e.StallType
            }).FirstOrDefault();

            return(View(vmPage2));
        }