예제 #1
0
        public IActionResult AddNewVendor(Vendor vendor, int wid)
        {
            int?id = HttpContext.Session.GetInt32(ID);

            if (id.HasValue)    // check id is in session
            {
                if (ModelState.IsValid)
                {
                    dbContext.AddNewVendor(vendor, wid);

                    return(RedirectToAction("UpdateWeddingForm", new { wid = wid }));
                }
                else
                {
                    ViewBag.WeddingId = wid;
                    return(View("NewVendorForm"));
                }
            }
            else
            {
                return(Redirect("/logout"));
            }
        }