public void AddContractEmployeLink(GetContractEmploye link) { Employe defaultEmploye = db.Employers.Include(data => data.Contracts).FirstOrDefault(data => data.Id == link.EmployeId); ViewContracts contract = new ViewContracts(); this.AddContract(contract); db.SaveChanges(); Contract defaultContract = db.Contracts.Include(data => data.Employe).Include(data => data.Supply).Last(); ContractsEmploye CE = new ContractsEmploye() { ContractId = defaultContract.Id, EmployeId = link.EmployeId }; defaultEmploye.Contracts.Add(CE); db.Entry(defaultEmploye).State = EntityState.Modified; db.SaveChanges(); }
public IActionResult PutCElink([FromBody] GetContractEmploye link) { dbService.AddContractEmployeLink(link); return(Ok()); }