public void Save(EditSaleProductViewModelIn vm)
 {
     _log.InfoFormat("Saving Sale Product");
     SaleProduct sp = _productRepository.GetById(vm.Id) as SaleProduct;
     if (sp == null)
         sp = _productFactory.CreateSaleProduct(sp.Id);
     sp.Brand         = _productBrandRepository.GetById(vm.BrandId);
     sp.Description   = vm.Description;
     sp.Packaging     = _productPackagingRepository.GetById(vm.PackagingId);
     sp.PackagingType = _productPackagingTypeRepository.GetById(vm.PackagingTypeId);
     sp.ProductCode   = vm.ProductCode;
     sp.Flavour       = _productFlavourRepository.GetById(vm.FlavourID);
     sp.ProductType   = _productTypeRepository.GetById(vm.ProductTypeID);
     sp.ExFactoryPrice = vm.ExFactoryPrice;
     if (vm.VatClassId != Guid.Empty)
         sp.VATClass = _vatClassRepository.GetById(vm.VatClassId);
     if (vm.ReturnableProductId != null)
         sp.ReturnableProduct = _productRepository.GetById(vm.ReturnableProductId.Value) as ReturnableProduct;
     _productRepository.Save(sp);
 }
Esempio n. 2
0
        public ActionResult Edit(EditSaleProductViewModelIn vm)
        {
            try
            {
                return View(_productViewModelBuilder.CreateEditSaleProductViewModel(vm.Id));
            }
            catch (Exception ex)
            {
                return View();
            }

        }
Esempio n. 3
0
        public ActionResult EditSaleProduct(EditSaleProductViewModelIn vm)
        {

            try
            {
                _productViewModelBuilder.Save(vm);
                TempData["msg"] = "Sale Product Successfully Edited";
                return RedirectToAction("Index");
            }
            catch (DomainValidationException dve)
            {
                ValidationSummary.DomainValidationErrors(dve, ModelState);
                ViewBag.ReturnableProductList = _productViewModelBuilder.GetReturnableProducts();
                ViewBag.BrandsList = _productViewModelBuilder.GetBrands();
                ViewBag.FlavoursList = _productViewModelBuilder.GetFlavours();
                ViewBag.PackagingsList = _productViewModelBuilder.GetPackaging();
                ViewBag.PackTypeList = _productViewModelBuilder.GetPackagingType();
                ViewBag.ProductTypeList = _productViewModelBuilder.GetProductType();
                ViewBag.VatClassList = _productViewModelBuilder.VatClass();
                ViewBag.Title = "Add Product";
                ViewBag.msg = dve.Message;
                return View();
            }
            catch (Exception exx)
            {
                ViewBag.msg = exx.Message;
                ViewBag.ReturnableProductList = _productViewModelBuilder.GetReturnableProducts();
                ViewBag.BrandsList = _productViewModelBuilder.GetBrands();
                ViewBag.FlavoursList = _productViewModelBuilder.GetFlavours();
                ViewBag.PackagingsList = _productViewModelBuilder.GetPackaging();
                ViewBag.PackTypeList = _productViewModelBuilder.GetPackagingType();
                ViewBag.ProductTypeList = _productViewModelBuilder.GetProductType();
                ViewBag.VatClassList = _productViewModelBuilder.VatClass();
                ViewBag.Title = "Add Product";
               
                return View();
            }
        }
Esempio n. 4
0
 public ActionResult EditSaleProduct(EditSaleProductViewModelIn vm)
 {
   
     try
     {
         _productViewModelBuilder.Save(vm);
         _auditLogViewModelBuilder.AddAuditLog(this.User.Identity.Name, "Edit", "Sale Product", DateTime.Now);
         TempData["msg"] = "Sale Product Successfully Edited";
         return RedirectToAction("Index");
     }
     catch (DomainValidationException dve)
     {
         ValidationSummary.DomainValidationErrors(dve, ModelState);
         ViewBag.ReturnableProductList = _productViewModelBuilder.GetReturnableProducts();
         ViewBag.BrandsList = _productViewModelBuilder.GetBrands();
         ViewBag.FlavoursList = _productViewModelBuilder.GetFlavours();
         ViewBag.PackagingsList = _productViewModelBuilder.GetPackaging();
         ViewBag.PackTypeList = _productViewModelBuilder.GetPackagingType();
         ViewBag.ProductTypeList = _productViewModelBuilder.GetProductType();
         ViewBag.VatClassList = _productViewModelBuilder.VatClass();
         _log.ErrorFormat("Error in editing sale product " + dve.Message);
         _log.InfoFormat("Error in editing sale product " + dve.Message);
         ViewBag.Title = "Add Product";
         ViewBag.msg = dve.Message;
         return View();
     }
     catch (Exception exx)
     {
         ViewBag.msg = exx.Message;
         ViewBag.ReturnableProductList = _productViewModelBuilder.GetReturnableProducts();
         ViewBag.BrandsList = _productViewModelBuilder.GetBrands();
         ViewBag.FlavoursList = _productViewModelBuilder.GetFlavours();
         ViewBag.PackagingsList = _productViewModelBuilder.GetPackaging();
         ViewBag.PackTypeList = _productViewModelBuilder.GetPackagingType();
         ViewBag.ProductTypeList = _productViewModelBuilder.GetProductType();
         ViewBag.VatClassList = _productViewModelBuilder.VatClass();
         _log.ErrorFormat("Error in editing sale product " + exx.Message);
         _log.InfoFormat("Error in editing sale product " + exx.Message);
         ViewBag.Title = "Add Product";
         
         return View();
     }
 }