public async Task UpdateJob(Job job) { if (await CheckJobValidity(job)) { //check if the location already Exists. if the location doesnt exist the default value returned is null var location = await context.Locations.SingleOrDefaultAsync(l => l.Name == job.Location.Name); if (location != null) { job.LocationID = location.ID; job.Location = location; } else { context.Locations.Add(job.Location); } if (job.JobDescriptionDocument != null) { var jd = await context.JobDescriptions.FindAsync(job.ID); if (jd != null) { var newJD = job.JobDescriptionDocument; jd.Document = newJD.Document; jd.DocumentName = newJD.DocumentName; jd.DocumentType = newJD.DocumentType; jd.ValidityConfirmed = false; jd.LastUpdated = DateTime.Now; job.JobDescriptionDocument = jd; context.Entry(jd).State = EntityState.Modified; await Inisra.Solr.Operations.SolrOperations.AddJobDescriptionAsync( fileStream : new System.IO.MemoryStream(jd.Document), id : "" + jd.JobID, resourceName : jd.DocumentName, owner : job.Company.Name, title : job.Title ); } else { context.JobDescriptions.Add(job.JobDescriptionDocument); } } //check if the applications deadline is modified if yes then chck if its later than current date. context.Entry(job).State = EntityState.Modified; await context.SaveChangesAsync(); } }
public async Task <IHttpActionResult> PutSkill(int id, Skill skill) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != skill.ID) { return(BadRequest()); } db.Entry(skill).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SkillExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task UpdateJobSeeker(JobSeeker jobSeeker) { if (CheckJobSeekerValidity(jobSeeker)) { context.Entry(jobSeeker).State = EntityState.Modified; await context.SaveChangesAsync(); } }
// public async Task <bool> UpdateCompanyAsync(Company company) { //todo: Maybe add a chech if the company exists or not before changing the modified context.Entry(company).State = EntityState.Modified; //context.Companies.Update(company); ---> Only available for EFCore implementation return(await context.SaveChangesAsync() == 1? true : false); //method return type could be chenged to reflect result of update }