public ActionResult Create(string title, string details) { bool fail = false; try { ToDoItem item = new ToDoItem() { AccountId = MTApp.CurrentRequestContext.CurrentAdministrator(MTApp).Id, Details = details, IsComplete = false, Title = title }; ToDoItemRepository repository = new ToDoItemRepository(MTApp.CurrentRequestContext); if (repository.Create(item)) { fail = false; } else { fail = true; } } catch (Exception ex) { fail = true; } string destination = "~/todo"; if (fail) { destination += "?failed=1"; } return(new RedirectResult(destination)); }
public ActionResult Create(string title, string details) { bool fail = false; try { ToDoItem item = new ToDoItem() { AccountId = MTApp.CurrentRequestContext.CurrentAdministrator(MTApp).Id, Details = details, IsComplete = false, Title = title }; ToDoItemRepository repository = new ToDoItemRepository(MTApp.CurrentRequestContext); if (repository.Create(item)) { fail = false; } else { fail = true; } } catch (Exception ex) { fail = true; } string destination = "~/todo"; if (fail) { destination += "?failed=1"; } return new RedirectResult(destination); }
public ToDoItem CreateItem([FromBody] ToDoItem toDoItem) { return(_toDoItemRepository.Create(toDoItem)); }