Example #1
0
        public async Task <IActionResult> PutNewEnrollment([FromRoute] int id, [FromBody] NewEnrollment newEnrollment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != newEnrollment.NewEnrollmentId)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NewEnrollmentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            newEnrollment = _context.NewEnrollments.Include(e => e.Department).FirstOrDefault(e => e.NewEnrollmentId == newEnrollment.NewEnrollmentId);

            return(Ok(newEnrollment));
        }
 /// <summary>
 /// Fills in cancer participants data.
 /// </summary>
 private void FillInCancerParticipantsData()
 {
     PreScreened.SendKeys("5");
     ScreenFailures.SendKeys("3");
     NewEnrollment.SendKeys("4");
     ActiveIntervention.SendKeys("2");
     CompletedIntervention.SendKeys("1");
     FollowUp.SendKeys("2");
     Discontinued.SendKeys("1");
 }
Example #3
0
        public async Task <IActionResult> PostNewEnrollment([FromBody] NewEnrollment newEnrollment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.NewEnrollments.Add(newEnrollment);
            await _context.SaveChangesAsync();

            newEnrollment = _context.NewEnrollments.Include(e => e.Department).FirstOrDefault(e => e.NewEnrollmentId == newEnrollment.NewEnrollmentId);
            return(CreatedAtAction("GetNewEnrollment", new { id = newEnrollment.NewEnrollmentId }, newEnrollment));
        }