public async Task <Department> UpdateDepartmentAsync(long id, DepartmentRequestDto department)
        {
            var entity = await _dbContext.Departments.SingleOrDefaultAsync(d => d.Id == id);

            entity.Name = department.Name;
            await _dbContext.SaveChangesAsync();

            return(entity);
        }
        public async Task <Department> CreateDepartmentAsync(DepartmentRequestDto department)
        {
            var entry = await _dbContext.Departments.AddAsync(new Department()
            {
                Name = department.Name,
            });

            await _dbContext.SaveChangesAsync();

            return(entry.Entity);
        }
Esempio n. 3
0
        public async Task <DepartmentResponseDto> CreateDepartment(DepartmentRequestDto department)
        {
            var result = await _departmentService.CreateDepartmentAsync(department);

            return(_mapper.Map <DepartmentResponseDto>(result));
        }
Esempio n. 4
0
        public async Task <DepartmentResponseDto> UpdateDepartment(long id, DepartmentRequestDto department)
        {
            var result = await _departmentService.UpdateDepartmentAsync(id, department);

            return(_mapper.Map <DepartmentResponseDto>(result));
        }