Ejemplo n.º 1
0
        public async Task TestForAddTodo()
        {
            // Act
            _todoModel.TaskId = await _todoService.Add(_todoModel.TaskName, _todoModel.UserId);

            Assert.IsTrue(_todoModel.TaskId > 0);
        }
Ejemplo n.º 2
0
 public ActionResult Add(NewTodo todo)
 {
     if (!this.ModelState.IsValid)
     {
         return(View(todo));
     }
     _todoService.Add(todo.Name);
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 3
0
        public ActionResult <TodoItem> Post(TodoItem todoItem)
        {
            var added = _todoService.Add(todoItem);

            if (added)
            {
                return(CreatedAtAction(nameof(Get), new { id = todoItem.Id }, todoItem));
            }
            return(BadRequest());
        }
        public IActionResult Post([FromBody] TodoReq todoReq)
        {
            var todo = mapper.Map <TodoModel>(todoReq);

            todo.User = GetCurrentUser();
            todoService.Add(todo);
            var todoDto = mapper.Map <TodoDto>(todo);

            return(CreatedAtAction(nameof(Get), new { id = todo.Id }, todoDto));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([FromBody] Todo item)
        {
            if (item == null)
            {
                return(BadRequest());
            }
            await _service.Add(item);

            return(CreatedAtRoute("GetTodo", new { Controller = "Todo", id = item.TodoId }, item));
        }
Ejemplo n.º 6
0
        public async Task <ActionResult <TodoItem> > PostTodoItem(TodoItem todoItem)
        {
            if (_todoService.Add(todoItem))
            {
                // TodoItem was added successfully
                return(CreatedAtAction(nameof(GetTodoItem), new { id = todoItem.Id }, todoItem));
            }

            // Something went wrong internally with adding the TodoItem
            return(StatusCode(StatusCodes.Status500InternalServerError));
        }
Ejemplo n.º 7
0
        public IActionResult AddItem([FromBody] Todo todo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            _todoService.Add(todo);

            return(Created($"/{todo.Id}", todo));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Create(TodoDto todoDTO)
        {
            if (!ModelState.IsValid)
            {
                return(CustomResponse(ModelState));
            }
            var todo = _mapper.Map <Todo>(todoDTO);
            await _todoService.Add(todo);

            return(CustomResponse("Categoria de despesa cadastrada com sucesso"));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Add([FromBody] TodoAddInput addInput)
        {
            var result = await _todoService.Add(addInput);

            if (!result.Success)
            {
                return(BadRequest(result.Message));
            }

            return(CreatedAtAction("GetTodo", new { todoId = result.Data.Id }, result.Data));
        }
Ejemplo n.º 10
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var result = _todoService.Add(new TodoEntity
            {
                Id               = Guid.NewGuid(),
                Title            = txtBoxTitle.Text,
                ShortDescription = txtBoxShortDesc.Text,
                Description      = txtBoxDesc.Text,
                Status           = (Status)cmbBoxStatus.SelectedItem,
                ImportanceLevel  = Convert.ToInt32(txtBoxImportanceLevel.Text)
            });

            if (result > 0)
            {
                MessageBox.Show(GlobalConstants.AddSuccess, GlobalConstants.CaptionInfo, MessageBoxButtons.OK, MessageBoxIcon.Information);

                DialogResult dialogResult = MessageBox.Show(
                    GlobalConstants.AddOperationContinue,
                    GlobalConstants.CaptionQuestion,
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Question);

                if (dialogResult == DialogResult.Yes)
                {
                    ClearTextBoxesValue();
                }
                else
                {
                    Form getAllForm = Application.OpenForms["GetAllForm"];

                    if (getAllForm == null)
                    {
                        getAllForm               = new GetAllForm();
                        getAllForm.MdiParent     = Application.OpenForms["ToDoListForm"];
                        getAllForm.StartPosition = FormStartPosition.CenterScreen;
                        getAllForm.Show();
                        this.Close();
                    }
                    else
                    {
                        GroupBox     listGroupBox = (GroupBox)getAllForm.Controls["grpList"];
                        DataGridView dataGrid     = (DataGridView)listGroupBox.Controls["dataGrdGetAll"];
                        dataGrid.DataSource            = null;
                        dataGrid.DataSource            = _todoService.GetAll();
                        dataGrid.Columns["Id"].Visible = false;
                        this.Close();
                    }
                }
            }
            else
            {
                MessageBox.Show(GlobalConstants.AddError, GlobalConstants.CaptionInfo, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 11
0
        public bool Add(AddTodoDto addTodoDto, int userId)
        {
            var todo = new Todo()
            {
                Description      = addTodoDto.Description,
                UserId           = userId,
                ModificationDate = DateTime.Now,
                Done             = false
            };

            return(todoService.Add(todo));
        }
Ejemplo n.º 12
0
        public async Task <ActionResult> Add(Todo t)
        {
            try
            {
                var result = await TodoService.Add(t);

                return(View("Index"));
            }
            catch (HttpRequestException e)
            {
                ViewBag.Error = e;
                return(View("Error"));
            }
        }
Ejemplo n.º 13
0
        public IActionResult Add([FromBody] TodoDto obj)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Todo todo = new Todo()
            {
                Text = obj.Text
            };

            _todoService.Add(todo);

            return(CreatedAtAction(nameof(Todo), new { id = todo.Id }, obj));
        }
Ejemplo n.º 14
0
        public IActionResult Add(Todo todo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            todo.CreatedDate = DateTime.Now;
            var result = _todoService.Add(todo);

            if (result.Success)
            {
                return(Ok(result));
            }

            return(BadRequest(result));
        }
Ejemplo n.º 15
0
        public IActionResult Post([FromBody] TodoItem item)
        {
            if (item == null)
            {
                return(BadRequest());
            }
            var result = _todoService.Add(item);

            if (result > 0)
            {
                return(new JsonResult(new { Success = true }));
            }
            else
            {
                return(new JsonResult(new { Success = false }));
            }
        }
Ejemplo n.º 16
0
        public IActionResult Add(TodoEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                model.Todo.CreatedAt = DateTime.Now;
                model.Todo.UpdatedAt = DateTime.Now;
                _todoService.Add(model.Todo);
                TempData["success"] = "Todo item is successfully added!";

                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("Error", "Some error(s) accured while attempting to save changes");
                return(View(model));
            }
        }
Ejemplo n.º 17
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int result = 0;

            if (!GlobalMethods.TextBoxIsNullOrEmpty(this))
            {
                result = _todoService.Add(new TodoEntity
                {
                    Id               = Guid.NewGuid(),
                    Title            = txtTitle.Text,
                    ShortDescription = txtShort.Text,
                    Description      = txtDesc.Text,
                    ImportanceLevel  = (ImportanceLevel)cmbImportanceLevel.SelectedItem,
                    Status           = (Status)cmbStatus.SelectedItem
                });
            }

            if (result > 0)
            {
                MessageBox.Show(GlobalConstants.AddSuccess, GlobalConstants.CaptionInfo, MessageBoxButtons.OK, MessageBoxIcon.Information);
                DialogResult dialogResult = MessageBox.Show(GlobalConstants.AddOperationAgain, GlobalConstants.CaptionQuestion, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dialogResult == DialogResult.Yes)
                {
                    GlobalMethods.Clear(this);
                }
                else
                {
                    Form getAllForm = new getAllForm
                    {
                        MdiParent     = Application.OpenForms[GlobalConstants.TodoAppForm],
                        StartPosition = FormStartPosition.CenterScreen
                    };
                    getAllForm.Show();
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show(GlobalConstants.AddError, GlobalConstants.CaptionInfo, MessageBoxButtons.OK, MessageBoxIcon.Error);
                GlobalMethods.Clear(this);
            }
        }
Ejemplo n.º 18
0
 public IActionResult Create([FromBody] TodoModel model)
 {
     _service.Add(model);
     return(Ok(model));
 }
Ejemplo n.º 19
0
        public async Task <IActionResult> Add(TodoItemModel newItem)
        {
            await service.Add(newItem);

            return(Ok());
        }
Ejemplo n.º 20
0
        public IActionResult Post(Todo todo)
        {
            var services = _service.Add(todo).GetAwaiter().GetResult();

            return(Ok(services));
        }
Ejemplo n.º 21
0
        public IActionResult Create(TodoItem item)
        {
            var itemId = _todoService.Add(item);

            return(CreatedAtRoute("GetTodo", new { id = itemId }, item));
        }
Ejemplo n.º 22
0
        public IActionResult Add(Todo todo)
        {
            var temp = _todoService.Add(todo);

            return(Ok(temp));
        }
Ejemplo n.º 23
0
 public void Post([FromBody] TodoModel todo)
 {
     _todoService.Add(todo);
 }
Ejemplo n.º 24
0
 public IActionResult Create(Todo todo)
 {
     _todoService.Add(todo);
     return(Created(string.Empty, todo));
 }
Ejemplo n.º 25
0
 public async Task <int> Create(TodoModel model)
 {
     return(await _todoService.Add(model.TaskName, _userContext.UserId));
 }