public bool CreateSquad(SquadCreate model) { var entity = new Squad() { PlatoonId = model.PlatoonId, Platoon = model.Platoon, Name = model.Name, Familiar = model.Familiar }; using (var ctx = new ApplicationDbContext()) { ctx.SquadDbSet.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(SquadCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateSquadService(); if (service.CreateSquad(model)) { TempData["Save Result"] = "Record created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Unable to create record."); return(View(model)); }