public async Task <IActionResult> PutMThrmssourcing([FromRoute] long id, [FromBody] MThrmssourcing mThrmssourcing) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != mThrmssourcing.MThrmssourcingId) { return(BadRequest()); } _context.Entry(mThrmssourcing).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MThrmssourcingExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostMThrmssourcing([FromBody] MThrmssourcing mThrmssourcing) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.MThrmssourcing.Add(mThrmssourcing); await _context.SaveChangesAsync(); var _candidate = new MThrmscvrepository() { MThrmscvrepositoryId = (long)mThrmssourcing.CandidateId, Status = "sourcing" }; using (var newContext = new AMTDEVContext()) { newContext.MThrmscvrepository.Attach(_candidate); newContext.Entry(_candidate).Property(X => X.Status).IsModified = true; newContext.SaveChanges(); } var _shortlistrecord = new MThrmsshortlist() { MThrmsshortlistId = 0, ManPowerId = mThrmssourcing.ManPowerId, DesignationId = mThrmssourcing.DesignationId, ResourceRequisitionId = mThrmssourcing.ResourceRequisitionId, JobCode = mThrmssourcing.JobCode, ResourceAllocationId = mThrmssourcing.ResourceAllocationId, RecruiterId = mThrmssourcing.RecruiterId, SourcingId = mThrmssourcing.MThrmssourcingId, CandidateId = mThrmssourcing.CandidateId }; using (var newContext = new AMTDEVContext()) { newContext.MThrmsshortlist.Add(_shortlistrecord); newContext.SaveChanges(); } return(CreatedAtAction("GetMThrmssourcing", new { id = mThrmssourcing.MThrmssourcingId }, mThrmssourcing)); }