public bool CreateWeek(WeekCreate model) { var entity = new Week() { OwnerId = _userId, SeasonNumber = model.SeasonNumber, SeasonWeek = model.SeasonWeek, StadiumName = model.StadiumName, PlayerId = model.PlayerId }; using (var ctx = new ApplicationDbContext()) { ctx.Weeks.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(WeekCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateWeekService(); if (service.CreateWeek(model)) { TempData["SaveResult"] = "Your week was updated."; return(RedirectToAction("Index")); } return(View(model)); }