public async Task <Departmentmodel> GetDepartmentByIdAsync(int DepartmentId)
        {
            var result = await _dbContext.Departments.FindAsync(DepartmentId);

            var Departpar = new Departmentmodel
            {
                Department_ID   = result.Department_ID,
                Department_Name = result.Department_Name,
                Description     = result.Description
            };

            return(Departpar);
        }
        public async Task <int> AddDepartmentAsync(Departmentmodel departmentmodel)
        {
            var Depart = new Department
            {
                Department_ID   = departmentmodel.Department_ID,
                Department_Name = departmentmodel.Department_Name,
                Description     = departmentmodel.Description,
            };

            await _dbContext.Departments.AddAsync(Depart);

            return(await _dbContext.SaveChangesAsync());
        }
Пример #3
0
 public async Task <ActionResult <int> > Post([FromBody] Departmentmodel departmentmodel)
 {
     return(Ok(await _DepartmentService.AddDepartmentAsync(departmentmodel)));
 }