public ActionResult C(Todo todo)
        {
            try
            {
                todo.Description = todo.Description.Trim();
                todo.CreatedAt   = DateTime.Now;

                Repository.AddTodo(todo);

                return(RedirectToAction("T"));
            }
            catch
            {
                return(MobileView("Error"));
            }
        }
Esempio n. 2
0
        public IHttpActionResult CreateTodo([FromBody] TodoDTO newTodo)
        {
            var todoEntity = Mapper.Map <Entities.Todo>(newTodo);

            _todoRepository.AddTodo(todoEntity);
            if (!_todoRepository.Save())
            {
                return(BadRequest("A problem happened while handling your request."));
            }
            var savedTodo = Mapper.Map <Models.TodoDTO>(todoEntity);

            return(Ok(savedTodo));
        }
        public ActionResult Create(Todo todo)
        {
            try
            {
                todo.Description = todo.Description.Trim();
                todo.CreatedAt   = DateTime.Now;

                Repository.AddTodo(todo);

                TodoDTO dto = new TodoDTO()
                {
                    Process = Repository.GetProcess(),
                    Todos   = Repository.GetAllTodos()
                };

                return(PartialView("todos", dto));
            }
            catch (Exception ex)
            {
                Response.StatusCode = 400;
                return(Content(ex.Message));
            }
        }
Esempio n. 4
0
        public ActionResult Todo(Todo todo)
        {
            try
            {
                todo.Description = todo.Description.Trim();
                todo.CreatedAt   = DateTime.Now;

                repository.AddTodo(todo);

                return(PartialView("aTodo", todo));
            }
            catch
            {
                Response.StatusCode = 400;
                return(PartialView("aTodo", todo));
            }
        }
Esempio n. 5
0
        private async void onSave(object sender, EventArgs e)
        {
            //using (SQLite.SQLiteConnection conn = new SQLite.SQLiteConnection(App.DB_PATH))
            //{
            //    conn.CreateTable<Todo>();
            //    var numberOfRows = conn.Insert(list);


            //    if (numberOfRows > 0 )
            //        DisplayAlert("Success", "Your task is inserted", "OK!");
            //    else
            //        DisplayAlert("Failure", "Your task cannot inserted", "Try again");
            //}



            var task = (Todo)BindingContext;

            _todoRepo.AddTodo(task);

            await DisplayAlert("Success", "Your task is inserted", "OK!");

            await Navigation.PushAsync(new MainPage());
        }
Esempio n. 6
0
 public IActionResult Add(string title)
 {
     TodoRepository.AddTodo(title);
     return(RedirectToAction("List"));
 }
Esempio n. 7
0
 public void AddTodo(string title, int id)
 {
     TodoRepository.AddTodo(title, id);
 }
Esempio n. 8
0
 public IActionResult Add(Todo todo) //, User user)
 {
     TodoRepository.AddTodo(todo);
     return(RedirectToAction("List"));
 }
Esempio n. 9
0
        public ActionResult <Todo> AddToDo([FromBody] Todo todo)
        {
            var todoRepository = new TodoRepository(_toDoContext);

            return(todoRepository.AddTodo(todo).Result);
        }