public ActionResult Create(ArmyBLL Record) { //var errors = ModelState.Values.SelectMany(v => v.Errors); //ModelState["ArmyID"].Errors.Clear();// These are expected to be empty so ignored //ModelState["UserID"].Errors.Clear();// These are expected to be empty so ignored if (!ModelState.IsValid) { return(View(Record)); } int NewArmyID = 0; try { using (ContextBLL ctx = new ContextBLL()) { UserBLL me = ctx.UserFindByName(User.Identity.Name); Record.UserID = me.UserID; NewArmyID = ctx.ArmyCreate(Record); } return(RedirectToAction("Details", new { id = NewArmyID })); } catch (Exception oops) { Error.Log(oops); return(View("error", oops)); } }
public ActionResult Create(ArmyBLL NewArmy) { if (!ModelState.IsValid) { return(View(NewArmy)); } try { int NewArmyID = 0; using (ContextBLL ctx = new ContextBLL()) { NewArmyID = ctx.ArmyCreate(NewArmy); } return(RedirectToAction("Details", new { id = NewArmyID })); } catch (Exception oops) { Error.Log(oops); return(View("Error", oops)); } }