public async Task <TasksCategories> Add(TasksCategories entity)
        {
            context.Set <TasksCategories>().Add(entity);
            await context.SaveChangesAsync();

            return(entity);
        }
        public TasksCategories update(TasksCategories updatedTasksCategories)
        {
            var tasksCategories = _context.TasksCategories.Update(updatedTasksCategories);

            _context.SaveChanges();
            return(updatedTasksCategories);
        }
        public TasksCategories update(TasksCategories updatedTasksCategories)
        {
            var taskCategory = _context.TasksCategories.Attach(updatedTasksCategories);

            taskCategory.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            _context.SaveChanges();
            return(updatedTasksCategories);
        }
        public async Task <TasksCategories> Update(TasksCategories entity)
        {
            context.TasksCategories.Update(entity);

            await context.SaveChangesAsync();

            return(entity);
        }
        public TasksCategories delete(int id)
        {
            TasksCategories tasksCategories = _context.TasksCategories.Find(id);

            _context.TasksCategories.Remove(tasksCategories);
            _context.SaveChanges();

            return(tasksCategories);
        }
        public async Task <ActionResult <TasksCategoriesViewModel> > Post(TasksCategoriesViewModel entity)
        {
            TasksCategories maped = _mapper.Map <TasksCategories>(entity);
            await _repository.Add(maped);



            return(Ok(entity));
        }
        public IActionResult Create(TaskCategoriesVM TaskCategories)
        {
            /* var task = _taskRepository.GetTask(TaskCategories.TaskId);
             * var catigory = _categoriesRepository.GetCategory(TaskCategories.CategoryId);
             * if (task == null || catigory == null) return NotFound();*/
            TasksCategories taskCategories = _mapper.Map <TasksCategories>(TaskCategories);

            _taskCategoriesRepository.Create(taskCategories);
            return(Ok(taskCategories));
        }
        public TasksCategories delete(int id)
        {
            TasksCategories taskCategory = _context.TasksCategories.Find(id);

            if (taskCategory != null)
            {
                _context.TasksCategories.Remove(taskCategory);
                _context.SaveChanges();
            }
            return(taskCategory);
        }
        public async Task <TasksCategories> Update(int CategoryId, int TaskId, TasksCategories entity)
        {
            await Delete(CategoryId, TaskId);

            context.TasksCategories.Add(entity);

            await context.SaveChangesAsync();


            return(entity);
        }
        public IActionResult Update(int TaskId, [FromBody] TaskCategoriesVM TaskCategories)
        {
            TasksCategories taskCategories = _taskCategoriesRepository.GetTaskCategoryByTaskID(TaskId);

            if (taskCategories == null)
            {
                return(NotFound());
            }
            _mapper.Map(TaskCategories, taskCategories);
            _taskCategoriesRepository.Update(taskCategories);
            return(Ok(_mapper.Map <TaskCategoriesVM>(taskCategories)));
        }
        public async Task <IActionResult> Put(int categoryId, int taskId, TasksCategoriesViewModel entity)
        {
            TasksCategories maped       = _mapper.Map <TasksCategories>(entity);
            var             updatedTask = await _repository.Update(categoryId, taskId, maped);

            if (updatedTask == null)
            {
                return(NotFound());
            }


            return(Ok(entity));
        }
        /*[Route("Task")]
         * [HttpGet("{TaskId}")]*/
        public IActionResult GetTaskCategoryByTaskID(int TaskID)
        {
            TasksCategories taskCategory = _taskCategoriesRepository.GetTaskCategoryByTaskID(TaskID);

            return(Ok(_mapper.Map <TaskCategoriesVM>(taskCategory)));
        }
 public TasksCategories Create(TasksCategories TaskCategory)
 {
     _context.TasksCategories.Add(TaskCategory);
     _context.SaveChanges();
     return(TaskCategory);
 }
        public TasksCategories GetTaskCategoryByTaskID(int TaskCategoryId)
        {
            TasksCategories taskCategory = _context.TasksCategories.Find(TaskCategoryId);

            return(taskCategory);
        }
        public TasksCategories getTasksCategoriesById(int id)
        {
            TasksCategories tasksCategories = _context.TasksCategories.Find(id);

            return(tasksCategories);
        }
 public TasksCategories Update(TasksCategories TaskCategory)
 {
     throw new NotImplementedException();
 }
 public TasksCategories createTasksCategories(TasksCategories newTasksCategories)
 {
     _context.TasksCategories.Add(newTasksCategories);
     _context.SaveChanges();
     return(newTasksCategories);
 }