public IActionResult Add([FromBody] EmployeeContractViewModel Vm) { try { var companyExpired = _companyDetailService.CheckCompanyExpried(Vm.CompanyId); if (companyExpired != null) { return(new OkObjectResult(companyExpired)); } var data = _employeeContractService.Add(Vm, _companyDetailService.GetById(Vm.CompanyId).CompanyCode); SaveChanges(); 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))); } }
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))); } }