示例#1
0
        public async Task <IActionResult> PutTraining([FromRoute] int id, [FromBody] Training training)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != training.TrainingId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
示例#2
0
        public async Task <IActionResult> PutTrainingClassStudent([FromRoute] int trainingClassId, [FromBody] TrainingClassParticipant trainingClassParticipant)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!TrainingClassParticipantExists(trainingClassId, trainingClassParticipant.MemberID))
            {
                var trainingClassStudent = new TrainingClassStudent()
                {
                    TrainingClassId = trainingClassId,
                    TrainingClassStudentMemberId = trainingClassParticipant.MemberID,
                    TrainingClassStudentHours    = trainingClassParticipant.Hours,
                    Created = DateTime.UtcNow
                };

                try
                {
                    _context.TrainingClassStudent.Add(trainingClassStudent);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TrainingClassStudentExists(trainingClassId, trainingClassParticipant.MemberID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            return(NoContent());
        }
示例#3
0
        public async Task <IActionResult> PutOperationMember([FromRoute] int operationId, [FromRoute] int memberId)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!OperationMemberExists(operationId, memberId))
            {
                var operationMember = new OperationMember()
                {
                    OperationId = operationId,
                    MemberId    = memberId,
                    Created     = DateTime.UtcNow
                };

                try
                {
                    _context.OperationMember.Add(operationMember);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OperationMemberExists(operationId, memberId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
            }

            return(NoContent());
        }