예제 #1
0
        public ODataActionTests_Product UpdateRating2OnODataActionTests_RatedProduct([FromODataUri] int key, ODataActionParameters parameters)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, new ODataError()
                {
                    Message = ODataActionTests.GetModelStateErrorInformation(this.ModelState)
                }));
            }

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

            if (ratedProduct == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

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

            return(ratedProduct);
        }
예제 #2
0
        public ODataActionTests_Product ExtendSupportDate2([FromODataUri] int key, ODataActionParameters parameters)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, new ODataError()
                {
                    Message = ODataActionTests.GetModelStateErrorInformation(this.ModelState)
                }));
            }

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

            if (product == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

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

            return(product);
        }