コード例 #1
0
 public static DalWProfile.WorkingProfileDocument ApiToDal(this WorkingProfileDocument d)
 {
     return(new DalWProfile.WorkingProfileDocument()
     {
         Id = d.Id,
         Description = d.Description,
         Link = d.Link,
         Name = d.Name,
         CategoryId = d.CategoryId,
         SchoolYear = d.SchoolYear,
         Trimester = d.Trimester,
         SchoolYearCategoryId = d.SchoolYearCategoryId
     });
 }
        [HttpPut]/*POSTMAN OK*/
        public IActionResult Update([FromBody] WorkingProfileDocument doc)
        {
            switch (_workDocRepo.Update(doc.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 1 and 3.", 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));
            }
        }