public async Task TestForAddTodo() { // Act _todoModel.TaskId = await _todoService.Add(_todoModel.TaskName, _todoModel.UserId); Assert.IsTrue(_todoModel.TaskId > 0); }
public ActionResult Add(NewTodo todo) { if (!this.ModelState.IsValid) { return(View(todo)); } _todoService.Add(todo.Name); return(RedirectToAction("Index")); }
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)); }
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)); }
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)); }
public IActionResult AddItem([FromBody] Todo todo) { if (!ModelState.IsValid) { return(BadRequest()); } _todoService.Add(todo); return(Created($"/{todo.Id}", todo)); }
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")); }
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)); }
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); } }
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)); }
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")); } }
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)); }
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)); }
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 })); } }
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)); } }
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); } }
public IActionResult Create([FromBody] TodoModel model) { _service.Add(model); return(Ok(model)); }
public async Task <IActionResult> Add(TodoItemModel newItem) { await service.Add(newItem); return(Ok()); }
public IActionResult Post(Todo todo) { var services = _service.Add(todo).GetAwaiter().GetResult(); return(Ok(services)); }
public IActionResult Create(TodoItem item) { var itemId = _todoService.Add(item); return(CreatedAtRoute("GetTodo", new { id = itemId }, item)); }
public IActionResult Add(Todo todo) { var temp = _todoService.Add(todo); return(Ok(temp)); }
public void Post([FromBody] TodoModel todo) { _todoService.Add(todo); }
public IActionResult Create(Todo todo) { _todoService.Add(todo); return(Created(string.Empty, todo)); }
public async Task <int> Create(TodoModel model) { return(await _todoService.Add(model.TaskName, _userContext.UserId)); }