Пример #1
0
        //[Route("{id}")]
        public async Task <HttpStatusCode> UpdateEmployeeTask(EmployeeTaskCollection data)
        {
            try
            {
                if (data.EmployeeTasks?.Count > 0)
                {
                    //Wipe current entries first
                    await _employeetaskRepository.DeleteEmployeeTasksByTaskId(data.TaskId);

                    //Re-add Entries from Dto
                    foreach (var empTask in data.EmployeeTasks)
                    {
                        await _employeetaskRepository.InsertEmployeeTask(_mapper.Map <EmployeeTaskDto, EmployeeTask>(empTask));
                    }
                    return(HttpStatusCode.OK);
                }
                return(HttpStatusCode.NotFound);
            }
            catch (Exception)
            { throw; }
        }