/// <inheritdoc /> public async Task UpdateTask(ToDoDTO toDoDto) { var update = _mapper.Map <ToDo>(toDoDto); _toDoRepository.Update(update); await _toDoRepository.SaveChangesAsync(); }
public ToDoItem Get(int id) { ToDoDTO r = service.Get(1); return(new ToDoItem { Id = id }); }
public ToDoDTO Get(int id) { ToDoItem t = new ToDoItem { Id = 1, Name = "Example" }; ToDoDTO dto = Mapper.Map <ToDoDTO>(t); return(dto); }
public async Task <IActionResult> Update([FromBody] ToDoDTO toDoDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _toDoService.UpdateTask(toDoDto); _logger.LogInformation($"ToDo has been update"); return(Ok()); }
public string PostTodo(ToDoDTO todo) { using (APIEntities api = new APIEntities()) { var newTodo = new todo { todo_id = todo.ID, value = todo.Value, completed = (todo.Completed) ? 1 : 0 }; api.todoes.Add(newTodo); api.SaveChanges(); return("success"); } }
public IActionResult Put([FromBody] ToDoDTO tododto) { if (tododto == null) { return(BadRequest()); } var todo = _mapper.Map <ToDo>(tododto); string name = HttpContext.User.Identity.Name; int userId = _repository.GetUserId(name); todo.UserId = userId; _repository.Update(todo); _repository.Save(); return(Ok(todo)); }
public async Task <IActionResult> Create([FromBody] ToDoDTO toDoDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var userId = _identityService.GetUserIdByNameAsync(User.Identity.Name).ToString(); await _toDoService.AddNewTask(toDoDto, userId); _logger.LogInformation($"{userId} add new task"); return(Ok()); }
public async Task <ToDoDTO> ConvertToDTO(Todo toDo) { toDo.Person.Todos = null; ToDoDTO dto = new ToDoDTO { Title = toDo.Title, Description = toDo.Description, TodoId = toDo.TodoId, PersonId = toDo.PersonId, ParentId = toDo.ParentId, Todos = new List <ToDoDTO>(), PersonFullName = (toDo.Person.Name + " " + toDo.Person.Surname) }; foreach (Todo todo in await _todoRepository.GetAllChildItemsAsync(toDo)) { dto.Todos.Add(await ConvertToDTO(todo)); } return(dto); }
/// <inheritdoc /> public async Task AddNewTask(ToDoDTO toDoDto, string userId) { var todo = _mapper.Map <ToDo>(toDoDto); var profile = await _profileService.GetProfileIdByUserId(userId); todo.UserId = userId; if (profile != null) { todo.ProfileId = profile.Id.ToString(); } await _toDoRepository.AddAsync(todo); await _toDoRepository.SaveChangesAsync(); }
public void SetUp() { _mockService = new Mock <IToDoService>(); _toDoDTO = new ToDoDTO { Id = toDoId, Name = "Protect Qween Of The South", Description = "Guard", RowVersion = new byte[] { 4, 2 } }; getListDTO = new GetListsDTO { Skip = skip, Limit = limit, SearchString = searchString }; }
public async Task TodoUpdate_WithValidModel_Return_OkResult() { //Arrange var toDoDto = new ToDoDTO { Title = "FAKE", Description = "FAKE", IsComplete = false, Time = DateTime.Now.AddHours(2) }; //Act var result = await _controller.Update(toDoDto); //Assert Assert.IsType <OkResult>(result); }
public bool Put(int id, [FromBody] ToDoDTO model) { return(_appService.Update(model)); }
public ToDoDTO Post([FromBody] ToDoDTO model) { return(_appService.Create(model)); }
public bool Update(ToDoDTO toDo) { return(_service.Update(toDo.MapTo <ToDo>())); }
public ToDoDTO Create(ToDoDTO toDo) { return(_service.Create(toDo.MapTo <ToDo>()).MapTo <ToDoDTO>()); }