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

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutInternship(int id, InternshipDTO internshipDTO)
        {
            if (id != internshipDTO.Id)
            {
                return(BadRequest());
            }

            var internship = await _context.Internships.FindAsync(id);

            if (internship == null)
            {
                return(NotFound());
            }

            internship.Title       = internshipDTO.Title;
            internship.Description = internshipDTO.Description;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException) when(!InternshipExists(id))
            {
                return(NotFound());
            }

            return(NoContent());
        }