示例#1
0
        public async Task AddJob(Job job)
        {
            if (await CheckJobValidity(job))
            {
                //check if the location already Exists. if the location doesnt exist the default value returned is null
                // the "==" operator is case insensitive.
                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);
                }
                context.Jobs.Add(job);
                await context.SaveChangesAsync();

                var jd = job.JobDescriptionDocument;
                if (jd != null)
                {
                    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
                        );
                }
            }
        }
示例#2
0
        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));
        }
示例#3
0
        //
        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
        }
示例#4
0
 public async Task UpdateJobSeeker(JobSeeker jobSeeker)
 {
     if (CheckJobSeekerValidity(jobSeeker))
     {
         context.Entry(jobSeeker).State = EntityState.Modified;
         await context.SaveChangesAsync();
     }
 }