コード例 #1
0
        public HttpResponseMessage Update([FromBody] AssignmentAPIShortModel assignmentAPIShortModel)
        {
            if (assignmentAPIShortModel == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            if (_assignmentService.CheckIfAssignmentExists(assignmentAPIShortModel.LabNumber, assignmentAPIShortModel.Name) == true)
            {
                _assignmentService.UpdateAssignment(_assignmentAPIMapper.Map(_assignmentAPIShortModel.Map(assignmentAPIShortModel)));
                return(Request.CreateResponse(HttpStatusCode.Created, _assignmentAPIMapper.Map(_assignmentAPIShortModel.Map(assignmentAPIShortModel))));
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.Conflict, "Assignment not added yet!"));
            }
        }