コード例 #1
0
        public HttpResponseMessage Create(HttpRequestMessage request, CustomImageViewModel customImageVM)
        {
            return(CreateHttpResponse(request, () =>
            {
                HttpResponseMessage response = null;

                if (!ModelState.IsValid)
                {
                    response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
                }
                else
                {
                    CustomImage newCustomImage = new CustomImage();
                    newCustomImage.UpdateCustomImage(customImageVM);
                    newCustomImage.CreatedDate = DateTime.Now;
                    newCustomImage.CreatedBy = User.Identity.Name;
                    var page = _customImageService.Add(newCustomImage);
                    _customImageService.Save();
                    response = request.CreateResponse(HttpStatusCode.Created, page);
                }
                return response;
            }));
        }