Esempio n. 1
0
        public IHttpActionResult Put(int id, Product product)
        {
            var vm = new PTCViewModel();

            if (product == null)
            {
                return(NotFound());
            }

            vm.Entity   = product;
            vm.PageMode = PDSAPageModeEnum.Edit;
            vm.Save();

            if (!vm.IsValid)
            {
                if (vm.Messages.Count > 0)
                {
                    return(BadRequest(ConvertToModelState(vm.Messages)));
                }
                else if (vm.LastException != null)
                {
                    return(BadRequest(vm.Message));
                }
            }

            return(Ok(vm.Entity));
        }
Esempio n. 2
0
        public IHttpActionResult Post(Product product)
        {
            IHttpActionResult ret = null;
            var vm = new PTCViewModel();

            if (product != null)
            {
                vm.Entity   = product;
                vm.PageMode = PDSAPageModeEnum.Add;
                vm.Save();
                if (vm.IsValid)
                {
                    return(Created(Request.RequestUri + vm.Entity.ProductId.ToString(), vm.Entity));
                }
                else
                {
                    if (vm.Messages.Count > 0)
                    {
                        return(BadRequest(ConvertToModelState(vm.Messages)));
                    }
                    else
                    {
                        return(BadRequest(vm.Message));
                    }
                }
            }

            return(NotFound());
        }
Esempio n. 3
0
        public IHttpActionResult Post(Product product)
        {
            IHttpActionResult ret = null;
            PTCViewModel      vm  = new PTCViewModel();

            vm.Entity   = product;
            vm.PageMode = PageConstants.ADD;
            vm.Save();

            if (vm.IsValid)
            {
                ret = Created <Product>(
                    Request.RequestUri +
                    product.ProductId.ToString(),
                    product);
            }
            else if (vm.Messages.Count > 0)
            {
                ret = BadRequest(ConvertToModelState(vm.Messages));
            }
            else
            {
                ret = NotFound();
            }

            return(ret);
        }
Esempio n. 4
0
        public IHttpActionResult Put(int id,
                                     Product product)
        {
            IHttpActionResult ret = null;
            PTCViewModel      vm  = new PTCViewModel();

            vm.Entity   = product;
            vm.PageMode = PageConstants.EDIT;
            vm.Save();

            if (vm.IsValid)
            {
                ret = Ok(product);
            }
            else if (vm.Messages.Count > 0)
            {
                ret = BadRequest(ConvertToModelState(vm.Messages));
            }
            else
            {
                ret = NotFound();
            }

            return(ret);
        }
        public IHttpActionResult Put(int id, Product product)
        {
            IHttpActionResult ret = null;
            PTCViewModel      vm  = new PTCViewModel();

            if (product != null)
            {
                vm.Entity   = product;
                vm.PageMode = PDSAPageModeEnum.Edit;
                vm.Save();
                if (vm.IsValid)
                {
                    ret = Ok(vm.Entity);
                }
                else
                {
                    if (vm.Messages.Count > 0)
                    {
                        ret = BadRequest(ConvertToModelState(vm.Messages));
                    }
                    else if (vm.LastException != null)
                    {
                        ret = BadRequest(vm.Message);
                    }
                }
            }
            else
            {
                ret = NotFound();
            }

            return(ret);
        }
Esempio n. 6
0
        public IHttpActionResult Put(int id, Product product)
        {
            IHttpActionResult ret = null;
            var vm = new PTCViewModel();

            vm.Entity   = product;
            vm.PageMode = PageConstants.EDIT;
            vm.Save();

            if (vm.IsValid)
            {
                ret = Ok(product);
            }
            else
            {
                ret = NotFound();
            }

            return(ret);
        }
Esempio n. 7
0
        public IHttpActionResult Post(Product product)
        {
            IHttpActionResult ret = null;
            var vm = new PTCViewModel();

            vm.Entity   = product;
            vm.PageMode = PageConstants.ADD;
            vm.Save();

            if (vm.IsValid)
            {
                ret = Created(Request.RequestUri + product.ProductId.ToString(), product);
            }
            else
            {
                ret = NotFound();
            }

            return(ret);
        }