Beispiel #1
0
        public ActionResult Create(string id)
        {
            ProductPriceDetailView productPriceDetailView = new ProductPriceDetailView();

            #region Access Check
            bool hasPermission = GetEmployee().IsGuaranteed("ProductPrice_Insert");
            if (!hasPermission)
            {
                ModelState.AddModelError("", "AccessDenied");
                return(View(productPriceDetailView));
            }
            #endregion

            productPriceDetailView.EmployeeView = GetEmployee();

            GetRequest request = new GetRequest()
            {
                ID = Guid.Parse(id)
            };
            try
            {
                ProductView productView = new ProductView();
                productView = _productService.GetProduct(request).ProductView;

                productPriceDetailView.ProductPriceView             = new ProductPriceView();
                productPriceDetailView.ProductPriceView.ProductID   = productView.ID;
                productPriceDetailView.ProductPriceView.ProductName = productView.ProductName;
            }
            catch (Exception ex)
            {
                throw;
            }

            return(View(productPriceDetailView));
        }
Beispiel #2
0
        public ActionResult Create(ProductPriceDetailView productPriceDetailView)
        {
            #region Access Check
            bool hasPermission = GetEmployee().IsGuaranteed("ProductPrice_Insert");
            if (!hasPermission)
            {
                ModelState.AddModelError("", "AccessDenied");
                return(View(productPriceDetailView));
            }
            #endregion

            productPriceDetailView.EmployeeView = GetEmployee();

            GetRequest getCenterRequest = new GetRequest()
            {
                ID = productPriceDetailView.ProductPriceView.ProductID
            };
            productPriceDetailView.ProductPriceView.ProductName = _productService.GetProduct(getCenterRequest).ProductView.ProductName;

            if (ModelState.IsValid)
            {
                try
                {
                    AddProductPriceRequestOld request = new AddProductPriceRequestOld();
                    request.CreateEmployeeID  = GetEmployee().ID;
                    request.Discontinued      = productPriceDetailView.ProductPriceView.Discontinued;
                    request.Imposition        = productPriceDetailView.ProductPriceView.Imposition;
                    request.MaxDiscount       = productPriceDetailView.ProductPriceView.MaxDiscount;
                    request.Note              = productPriceDetailView.ProductPriceView.Note;
                    request.ProductID         = productPriceDetailView.ProductPriceView.ProductID;
                    request.ProductPriceTitle = productPriceDetailView.ProductPriceView.ProductPriceTitle;
                    request.SortOrder         = productPriceDetailView.ProductPriceView.SortOrder;
                    request.UnitPrice         = productPriceDetailView.ProductPriceView.UnitPrice;

                    GeneralResponse response = this._productPriceService.AddProductPrice(request);

                    if (response.success)
                    {
                        return(RedirectToAction("Index/" + request.ProductID));
                    }
                    else
                    {
                        foreach (string error in response.ErrorMessages)
                        {
                            ModelState.AddModelError("", error);
                        }
                        return(View(productPriceDetailView));
                    }
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                    return(View(productPriceDetailView));
                }
            }

            return(View(productPriceDetailView));
        }
Beispiel #3
0
        public ActionResult Edit(string id, ProductPriceDetailView productPriceDetailView)
        {
            #region Access Check
            bool hasPermission = GetEmployee().IsGuaranteed("ProductPrice_Update");
            if (!hasPermission)
            {
                ModelState.AddModelError("", "AccessDenied");
                return(View(productPriceDetailView));
            }
            #endregion

            productPriceDetailView.EmployeeView = GetEmployee();

            if (ModelState.IsValid)
            {
                try
                {
                    EditProductPriceRequestOld request = new EditProductPriceRequestOld();

                    request.ID = Guid.Parse(id);
                    request.ModifiedEmployeeID = GetEmployee().ID;
                    request.Discontinued       = productPriceDetailView.ProductPriceView.Discontinued;
                    request.Imposition         = productPriceDetailView.ProductPriceView.Imposition;
                    request.MaxDiscount        = productPriceDetailView.ProductPriceView.MaxDiscount;
                    request.Note              = productPriceDetailView.ProductPriceView.Note;
                    request.ProductID         = productPriceDetailView.ProductPriceView.ProductID;
                    request.ProductPriceTitle = productPriceDetailView.ProductPriceView.ProductPriceTitle;
                    request.SortOrder         = productPriceDetailView.ProductPriceView.SortOrder;
                    request.UnitPrice         = productPriceDetailView.ProductPriceView.UnitPrice;
                    request.RowVersion        = productPriceDetailView.ProductPriceView.RowVersion;

                    GeneralResponse response = this._productPriceService.EditProductPrice(request);

                    if (response.success)
                    {
                        return(RedirectToAction("Index/" + request.ProductID));
                    }
                    else
                    {
                        foreach (string error in response.ErrorMessages)
                        {
                            ModelState.AddModelError("", error);
                        }
                        return(View(productPriceDetailView));
                    }
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                    return(View(productPriceDetailView));
                }
            }

            return(View(productPriceDetailView));
        }
Beispiel #4
0
        public ActionResult Delete(string id)
        {
            ProductPriceDetailView productPriceDetailView = new ProductPriceDetailView();

            #region Access Check
            bool hasPermission = GetEmployee().IsGuaranteed("ProductPrice_Delete");
            if (!hasPermission)
            {
                ModelState.AddModelError("", "AccessDenied");
                return(View(productPriceDetailView));
            }
            #endregion

            productPriceDetailView.ProductPriceView = this.GetProductPriceView(id);
            productPriceDetailView.EmployeeView     = GetEmployee();

            return(View(productPriceDetailView));
        }
Beispiel #5
0
        public ActionResult Delete(string id, FormCollection collection)
        {
            ProductPriceDetailView productPriceDetailView = new ProductPriceDetailView();

            #region Access Check
            bool hasPermission = GetEmployee().IsGuaranteed("ProductPrice_Delete");
            if (!hasPermission)
            {
                ModelState.AddModelError("", "AccessDenied");
                return(View(productPriceDetailView));
            }
            #endregion

            productPriceDetailView.ProductPriceView = this.GetProductPriceView(id);
            productPriceDetailView.EmployeeView     = GetEmployee();

            DeleteRequest request = new DeleteRequest()
            {
                ID = Guid.Parse(id)
            };

            GeneralResponse response = this._productPriceService.DeleteProductPrice(request);

            if (response.success)
            {
                return(RedirectToAction("Index/" + productPriceDetailView.ProductPriceView.ProductID));
            }
            else
            {
                foreach (string error in response.ErrorMessages)
                {
                    ModelState.AddModelError("", error);
                }
                return(View(productPriceDetailView));
            }
        }