コード例 #1
0
        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);
        }
コード例 #2
0
 // Render a single item
 // GET: /ToDo/Render/
 public ActionResult Render(ToDoItem item)
 {
     return View(item);
 }