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"); }
protected void addTask_Click(object sender, EventArgs e) { var repo = new TaskRepository(); repo.Add(new Task() { Name = Name.Text }); }