Example #1
0
        public IEnumerable <ODataActionTests_Product> ExtendSupportDates2(ODataActionParameters parameters)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, new ODataError()
                {
                    Message = ODataActionTests.GetModelStateErrorInformation(this.ModelState)
                }));
            }

            foreach (ODataActionTests_Product prd in products)
            {
                prd.SupportedUntil = new DateTimeOffset(Convert.ToDateTime(parameters["newDate"].ToString()));
            }

            return(products);
        }
Example #2
0
        public IEnumerable <ODataActionTests_Product> UpdateRatings2OnCollectionOfODataActionTests_RatedProduct(ODataActionParameters parameters)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, new ODataError()
                {
                    Message = ODataActionTests.GetModelStateErrorInformation(this.ModelState)
                }));
            }

            IEnumerable <ODataActionTests_Product> ratedProducts = products.OfType <ODataActionTests_RatedProduct>();

            foreach (ODataActionTests_RatedProduct ratedProduct in ratedProducts)
            {
                ((ODataActionTests_RatedProduct)ratedProduct).Rating = Convert.ToInt32(parameters["newRating"].ToString());
            }

            return(ratedProducts);
        }
Example #3
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);
        }
Example #4
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);
        }