public static Task AddTask(string name) { var repo = new TaskRepository(); var task = new Task() {Name = name}; repo.Add(task); return task; }
public ActionResult AddTask(Task task) { var repo = new TaskRepository(); repo.Add(task); if(Request.IsAjaxRequest()) { return Json(task); } return new RedirectResult("/Home"); }
public void Add(Task task) { task.Id = tasks.Max(x => x.Id) + 1; tasks.Add(task); }