예제 #1
0
 public static DalWProfile.WorkingProfileQuestion ApiToDal(this WorkingProfileQuestion t)
 {
     return(new DalWProfile.WorkingProfileQuestion()
     {
         Id = t.Id,
         Subject = t.Subject,
         LastUpdate = t.LastUpdate,
         Question = t.Question,
         Correction = t.Correction,
         Explanation = t.Explanation,
         FirstHint = t.FirstHint,
         SecondHint = t.SecondHint,
         CategoryId = t.CategoryId,
         SchoolYear = t.SchoolYear,
         Trimester = t.Trimester,
         SchoolYearCategoryId = t.SchoolYear
     });
 }
        [HttpPut]/*POSTMAN OK*/
        public IActionResult Update([FromBody] WorkingProfileQuestion test)
        {
            switch (_testRepo.Update(test.ApiToDal()))
            {
            case DBErrors.Success:
                return(Ok());

            case DBErrors.TeachingCategoryId_NotFound:
                return(Problem("A valid TeachingCategoryId is needed.", statusCode: (int)HttpStatusCode.NotFound));

            case DBErrors.YearCategoryId_NotFound:
                return(Problem("A valid YearCategoryId is needed.", statusCode: (int)HttpStatusCode.NotFound));

            case DBErrors.IncorrectNumber:
                return(Problem("A Trimester should be between 0 and 4.", statusCode: (int)HttpStatusCode.BadRequest));

            case DBErrors.NullExeption:
                return(Problem("A mandatory field does not support 'null' value or is missing", statusCode: (int)HttpStatusCode.BadRequest));

            default:
                return(Problem("?", statusCode: (int)HttpStatusCode.NotFound));
            }
        }