public async Task <IActionResult> PutIntakeCapacity([FromRoute] int id, [FromBody] IntakeCapacity intakeCapacity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != intakeCapacity.IntakeCapacityId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PostIntakeCapacity([FromBody] IntakeCapacity intakeCapacity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.IntakeCapacity.Add(intakeCapacity);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetIntakeCapacity", new { id = intakeCapacity.IntakeCapacityId }, intakeCapacity));
        }
        public IActionResult AddOrUpdateCompletionRate([FromBody] IntakeCapacity intakeCapacity, [FromRoute] int departmentID)
        {
            var exists = _context.IntakeCapacity.Where(f => f.DepartmentId == departmentID).Any();

            if (!exists)
            {
                _context.Attach <IntakeCapacity>(intakeCapacity).State = EntityState.Added;
                _context.SaveChanges();
                return(Ok(intakeCapacity));
            }
            else
            {
                var cr = _context.IntakeCapacity.Where(f => f.DepartmentId == departmentID).First();
                _context.Update <IntakeCapacity>(cr).State = EntityState.Detached;

                intakeCapacity.IntakeCapacityId = cr.IntakeCapacityId;
                _context.Update <IntakeCapacity>(intakeCapacity).State = EntityState.Modified;
                _context.SaveChanges();
                return(Ok(intakeCapacity));
            }
        }