Example #1
0
        public IActionResult AddNewDepartment(DeptDto newDept)
        {
            if (newDept != null && newDept.Id == 0)
            {
                var added = _deptLogic.UpdateDept(newDept, OperationTypeEnum.Add);
                return(Ok(DtoTransfer.ConvertDeptToDto(added)));
            }

            return(BadRequest());
        }
Example #2
0
        public IActionResult UpdateDepartment(DeptDto updated)
        {
            if (updated != null && updated.Id != 0)
            {
                var result = _deptLogic.UpdateDept(updated);
                return(Ok(DtoTransfer.ConvertDeptToDto(result)));
            }

            return(BadRequest());
        }
Example #3
0
        public IActionResult DeactivateDepartment(int deptId)
        {
            if (deptId != 0)
            {
                var dept = _deptLogic.DeactivateDept(deptId);

                if (dept != null)
                {
                    return(Ok(DtoTransfer.ConvertDeptToDto(dept)));
                }

                return(NotFound());
            }

            return(BadRequest());
        }
Example #4
0
        public async Task <IActionResult> AddEmployeesAsync(int deptId, ICollection <string> empIds)
        {
            if (deptId != 0 && empIds != null && empIds.Count > 0)
            {
                var dept = await _deptLogic.AddEmployeesAsync(deptId, empIds);

                if (dept != null)
                {
                    return(Ok(DtoTransfer.ConvertDeptToDto(dept)));
                }

                return(NotFound());
            }

            return(BadRequest());
        }