public IActionResult checkout([Bind("OEmail", "OPh", "VId", "OName", "ODescr", "OFuncTime", "ONoOfGuests", "OFuncType")] Orders orders, int[] images) { ViewBag.error = 0; try { if (ModelState.IsValid) { foreach (var image in images) { db.Orders.Add(new Orders { OEmail = orders.OEmail, OPh = orders.OPh, VId = orders.VId, ImgId = image, ODate = DateTime.Now, OReadStatus = false, OName = orders.OName, ODescr = orders.ODescr, OFuncTime = orders.OFuncTime, ONoOfGuests = orders.ONoOfGuests, OFuncType = orders.OFuncType }); int effRows = db.SaveChanges(); if (effRows < 1) { ViewBag.error = 2; } } } else { ViewBag.error = 3; } } catch (Exception) { ViewBag.error = 2; } if (ViewBag.error == 0) { HttpContext.Session.Remove("Carts"); } return(View("Checkout")); }
public IActionResult CreateVolunteer([Bind("VName", "VAddress", "VContact")] Volunteer volunteer) { ViewBag.error = 0; try { if (ModelState.IsValid) { db.Volunteer.Add(volunteer); int effRows = db.SaveChanges(); if (effRows < 1) { ViewBag.error = 2; } } else { ViewBag.error = 3; } } catch (Exception) { ViewBag.error = 2; } return(View("AddVolunteer")); }