public async Task <DesignationLevel> DeleteDepartmentDesignationLevel(EditLevelDto editLevel) { var existingLevel = await _levelRepository.GetLevelIdMappedToDesignationDepartment(editLevel.DepartmentDesignationId); if (existingLevel != null) { existingLevel.IsDeleted = true; var levelDetails = await _levelRepository.GetAllDepartmentDesignationIdByLevelAsync(editLevel.LevelId); if (levelDetails == null) { var level = await _levelRepository.GetLevelByLevelId(editLevel.LevelId); level.IsDeleted = true; await _levelRepository.SaveChangesAsync(); } else { throw new Exception("this level have department Designation linked to it "); } return(existingLevel); } else { throw new Exception("Department Dessignation Doesn't exist"); } }
/// <summary> /// this method is used to add a new departmentdesignation to level /// </summary> /// <param name="editLevel"></param> /// <returns>add the new departmentdesignation to level </returns> public async Task <DesignationLevel> EditDepartmentDesignationLevel(EditLevelDto editLevel) { var existingLevel = await _levelRepository.GetLevelIdMappedToDesignationDepartment(editLevel.DepartmentDesignationId); if (existingLevel == null) { existingLevel.DepartmentDesignationId = editLevel.DepartmentDesignationId; existingLevel.LevelId = editLevel.LevelId; await _levelRepository.SaveChangesAsync(); return(existingLevel); } else { throw new Exception("This data alreay exists."); }; }
public async Task <ActionResult> DeleteDepartmentDesignationLevelAsync([FromBody] EditLevelDto editLevel) { await _levelService.DeleteDepartmentDesignationLevel(editLevel); return(Ok("Designation Department has been deleted.")); }
public async Task <ActionResult> EditDepartmentDesignationLevelAsync([FromBody] EditLevelDto editLevel) { return(Ok(await _levelService.EditDepartmentDesignationLevel(editLevel))); }