Beispiel #1
0
        public ODataActionTests_Product ExtendSupportDate2([FromODataUri] int key, ODataActionParameters parameters)
        {
#if !NETCORE // TODO #939: Enable this check for AspNetCore
            if (!ModelState.IsValid)
            {
                throw new System.Web.Http.HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, new ODataError()
                {
                    Message = ODataActionTests.GetModelStateErrorInformation(this.ModelState)
                }));
            }
#endif

            ODataActionTests_Product product = products.Where(prod => prod.ID == key).SingleOrDefault();

#if !NETCORE // TODO #939: Enable this check for AspNetCore
            if (product == null)
            {
                throw new System.Web.Http.HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }
#endif

            product.SupportedUntil = new DateTimeOffset(Convert.ToDateTime(parameters["newDate"].ToString()));

            return(product);
        }
Beispiel #2
0
        public ODataActionTests_Product UpdateRating1OnODataActionTests_RatedProduct([FromODataUri] int key, ODataActionParameters parameters)
        {
#if !NETCORE // TODO #939: Enable this check for AspNetCore
            if (!ModelState.IsValid)
            {
                throw new System.Web.Http.HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, new ODataError()
                {
                    Message = ODataActionTests.GetModelStateErrorInformation(this.ModelState)
                }));
            }
#endif

            ODataActionTests_Product ratedProduct = products.Where(prod => prod.ID == key).SingleOrDefault();

#if !NETCORE // TODO #939: Enable this check for AspNetCore
            if (ratedProduct == null)
            {
                throw new System.Web.Http.HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }
#endif

            ((ODataActionTests_RatedProduct)ratedProduct).Rating = Convert.ToInt32(parameters["newRating"].ToString());

            return(ratedProduct);
        }