public IActionResult create([FromBody] TaskCategoriesView newTaskCategory) { //[FromBody]-> because the task category attributes declaring in body in the postman var taskCategory = _mapper.Map <TasksCategories>(newTaskCategory); //it will map object from TaskCategoryView into TasksCategories _taskCategoriesRepository.createTasksCategories(taskCategory); return(Ok(taskCategory)); }
public IActionResult update(int id, [FromBody] TaskCategoriesView updatedTaskCategory) { //to update any attribute in task category by id var taskCategory = _taskCategoriesRepository.getTaskCategoriesById(id); if (taskCategory == null) { return(NotFound()); } _mapper.Map(updatedTaskCategory, taskCategory); return(Ok(_mapper.Map <TaskCategoriesView>(taskCategory))); }