public IActionResult GetPaging(int companyId, int page = 1, int pageSize = 20) { try { var companyExist = _companyDetailService.CheckCompanyExpried(companyId); if (companyExist != null) { return(new OkObjectResult(companyExist)); } if (page < 0) { page = 1; } if (pageSize < 0) { pageSize = 20; } var result = _departmentService.GetAllPaging(page, pageSize, companyId); return(new OkObjectResult(new GenericResult(result, true, ErrorMsg.SUCCEED, ErrorCode.SUCCEED_CODE))); } catch (Exception ex) { return(new OkObjectResult(new GenericResult(null, false, ErrorMsg.HAS_ERROR, ErrorCode.HAS_ERROR_CODE))); } }
public IActionResult GetById(int id, int companyId) { try { var companyExpired = _companyDetailService.CheckCompanyExpried(companyId); if (companyExpired != null) { return(new OkObjectResult(companyExpired)); } var data = _employeeContractService.GetById(id); return(new OkObjectResult(new GenericResult(data, true, ErrorMsg.SUCCEED, ErrorCode.SUCCEED_CODE))); } catch (Exception ex) { return(new OkObjectResult(new GenericResult(null, false, ErrorMsg.HAS_ERROR, ErrorCode.ERROR_CODE))); } }
private GenericResult CheckAccountCanLogin(AppUser user) { if (user.UserType == Roles.AdminCompany) { return(_companyDetailService.CheckCompanyExpried(user.CompanyId)); } if (user.UserType == Roles.Employee && (user.Status == Status.New || user.Status == Status.Expired)) { return(new GenericResult(null, false, ErrorMsg.ACCOUNT_EXPRIED_NEW, ErrorCode.LOGIN_FAILED)); } return(null); }
public IActionResult AddContractCompany([FromBody] ContractCompanyViewModel Vm) { try { if (!ModelState.IsValid) { var allErrors = ModelState.Values.SelectMany(v => v.Errors); return(new BadRequestObjectResult(new GenericResult(allErrors, false, ErrorMsg.DATA_REQUEST_IN_VALID, ErrorCode.ERROR_HANDLE_DATA))); } var bCheckExist = _companyDetailService.CheckCompanyExpried(Vm.CompanyId); if (bCheckExist != null) { return(new OkObjectResult(bCheckExist)); } Vm.Status = Status.New; var result = _contractCompany.Add(Vm, _companyDetailService.GetById(Vm.CompanyId).CompanyCode); return(new OkObjectResult(new GenericResult(result, true, ErrorMsg.SUCCEED, ErrorCode.SUCCEED_CODE))); } catch (Exception ex) { return(new OkObjectResult(new GenericResult(null, false, ErrorMsg.HAS_ERROR, ErrorCode.HAS_ERROR_CODE))); } }