Example #1
0
        public async Task <IActionResult> PutKnowledge(int id, Knowledge knowledge)
        {
            if (id != knowledge.Id)
            {
                return(BadRequest());
            }

            _context.Entry(knowledge).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!KnowledgeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #2
0
        public async Task <IActionResult> PutCandidate(int id, Candidate candidate)
        {
            if (id != candidate.Id)
            {
                return(BadRequest());
            }

            try
            {
                WorkLoad     workLoad     = candidate.WorkLoad;
                WorkSchedule workSchedule = candidate.WorkSchedule;
                List <CandidateKnowledge> candidateKnowledges        = candidate.CandidateKnowledges;
                List <CandidateKnowledge> candidateKnowledgesForSave = new List <CandidateKnowledge>();
                candidate.WorkSchedule          = null;
                candidate.WorkLoad              = null;
                _context.Entry(candidate).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                _context.Entry(workLoad).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                _context.Entry(workSchedule).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                foreach (CandidateKnowledge item in candidateKnowledges)
                {
                    _context.Entry(item).State = EntityState.Modified;
                    await _context.SaveChangesAsync();
                }
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CandidateExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }