public bool GoalCreate(Goal_Create model) { var entity = new Goals() { UserId = _userId, Title = Convert.ToString(model.Title), Content = Convert.ToString(model.Content), CreatedDate = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.goal.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(Goal_Create model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateGoalServices(); if (service.GoalCreate(model)) { TempData["SaveResult"] = "Your Goal Has Been Saved."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Goal Could not be Created."); return(View(model)); }