예제 #1
0
        public IActionResult OnPost()
        {
            Task = _taskData.Update(Task);
            _taskData.Commit();

            return(Page());
        }
예제 #2
0
        public IActionResult OnPost(int taskId)
        {
            var task = _taskData.Delete(taskId);

            _taskData.Commit();

            if (task == null)
            {
                return(RedirectToPage("./NotFound"));
            }

            TempData["Message"] = $"Task '{task.Title}' deleted!";
            return(RedirectToPage("./List"));
        }
예제 #3
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                Status   = _htmlHelper.GetEnumSelectList <TaskStatus>();
                Priority = _htmlHelper.GetEnumSelectList <TaskPriority>();
                return(Page());
            }

            if (Task.Id > 0)
            {
                _taskData.Update(Task);
                TempData["Message"] = "Task updated!";
            }
            else
            {
                _taskData.Add(Task);
                TempData["Message"] = "Task added!";
            }

            _taskData.Commit();
            return(RedirectToPage("./Detail", new { taskId = Task.Id }));
        }