Пример #1
0
        public ActionResult Create(ProductFormModel model, [DataSourceRequest] DataSourceRequest request)
        {
            Contract.Requires(model != null);

            if (this.ModelState.IsValid)
            {
                var product = this.ProductRepository.Create();

                //var orderHistory = this.OrderHistoryRepository.Create();

                ProductFormModel.ToData(product, model);

                this.ProductRepository.Insert(product);

                this.UnityOfWork.Save();

                model.Id = product.Id;
            }

            return(this.JsonNet(new[] { model }.ToDataSourceResult(request, this.ModelState)));
        }
Пример #2
0
        public ActionResult Update([DataSourceRequest] DataSourceRequest request, ProductFormModel model)
        {
            Contract.Requires(model != null);

            if (this.ModelState.IsValid)
            {
                var order = this.ProductRepository.GetById(model.Id);

                if (order == null)
                {
                    throw new Exception("Objednávka nenalezen.");
                }

                ProductFormModel.ToData(order, model);

                this.ProductRepository.Update(order);

                this.UnityOfWork.Save();
            }

            return(this.JsonNet(new[] { model }.ToDataSourceResult(request, this.ModelState)));
        }