public bool CreateLocationPrompt(LocationPromptCreate model) { var entity = new LocationPrompt() { AdminId = _userId, Location = model.Location, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.LocationPrompts.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(LocationPromptCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateLocationPromptService(); if (service.CreateLocationPrompt(model)) { TempData["Saveresult"] = "Your location was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Your location could not be created."); return(View(model)); }