public ActionResult AddOrEditVendor(Web.Models.ViewModels.Purchases.Vendor model)
        {
            Vendor vendor = null;

            if (model.Id != 0)
            {
                vendor = _purchasingService.GetVendorById(model.Id.Value);
            }
            else
            {
                vendor = new Vendor();
            }

            vendor.Party.Name = model.VendorName;
            vendor.AccountsPayableAccountId  = model.AccountsPayableAccountId.Value == -1 ? null : model.AccountsPayableAccountId;
            vendor.PurchaseAccountId         = model.PurchaseAccountId.Value == -1 ? null : model.PurchaseAccountId;
            vendor.PurchaseDiscountAccountId = model.PurchaseDiscountAccountId.Value == -1 ? null : model.PurchaseDiscountAccountId;

            if (model.Id != 0)
            {
                _purchasingService.UpdateVendor(vendor);
            }
            else
            {
                _purchasingService.AddVendor(vendor);
            }

            return(RedirectToAction("Vendors"));
        }
Exemplo n.º 2
0
        public ActionResult AddOrEditVendor(int id = 0)
        {
            Vendor vendor = null;
            var model = new Web.Models.ViewModels.Purchases.Vendor();
            model.Id = id;
            if (id != 0)
            {
                vendor = _purchasingService.GetVendorById(id);
                model.VendorName = vendor.Name;
                model.AccountsPayableAccountId = vendor.AccountsPayableAccountId;
                model.PurchaseAccountId = vendor.PurchaseAccountId;
                model.PurchaseDiscountAccountId = vendor.PurchaseDiscountAccountId;
            }

            return View(model);
        }
        public ActionResult AddOrEditVendor(int id = 0)
        {
            Vendor vendor = null;
            var    model  = new Web.Models.ViewModels.Purchases.Vendor();

            model.Id = id;
            if (id != 0)
            {
                vendor           = _purchasingService.GetVendorById(id);
                model.VendorName = vendor.Party.Name;
                model.AccountsPayableAccountId  = vendor.AccountsPayableAccountId;
                model.PurchaseAccountId         = vendor.PurchaseAccountId;
                model.PurchaseDiscountAccountId = vendor.PurchaseDiscountAccountId;
            }

            return(View(model));
        }