Ejemplo n.º 1
0
        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.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");
        }
Ejemplo n.º 2
0
 public ActionResult AddVendor(Models.ViewModels.Purchases.AddVendor model)
 {
     var vendor = new Vendor()
     {
         Name = model.VendorName,
         AccountsPayableAccountId = model.AccountsPayableAccountId.Value == -1 ? null : model.AccountsPayableAccountId,
         PurchaseAccountId = model.PurchaseAccountId.Value == -1 ? null : model.PurchaseAccountId,
         PurchaseDiscountAccountId = model.PurchaseDiscountAccountId.Value == -1 ? null : model.PurchaseDiscountAccountId,
     };
     _purchasingService.AddVendor(vendor);
     return RedirectToAction("Vendors");
 }
Ejemplo n.º 3
0
        public static Vendor InitVendor()
        {
            Vendor vendor = new Vendor();
            vendor.No = "1";
            vendor.Name = "ABC Sample Supplier";
            vendor.AccountsPayableAccountId = _context.Accounts.Where(a => a.AccountName == "Accounts Payable").FirstOrDefault().Id;
            vendor.PurchaseAccountId = _context.Accounts.Where(a => a.AccountName == "Purchase A/C").FirstOrDefault().Id;
            vendor.PurchaseDiscountAccountId = _context.Accounts.Where(a => a.AccountName == "Purchase Discounts").FirstOrDefault().Id;
            vendor.PartyType = Core.Domain.PartyTypes.Vendor;
            vendor.CreatedBy = "System";
            vendor.CreatedOn = DateTime.Now;
            vendor.ModifiedBy = "System";
            vendor.ModifiedOn = DateTime.Now;

            Contact primaryContact = new Contact();
            primaryContact.ContactType = ContactTypes.Vendor;
            primaryContact.PartyType = PartyTypes.Contact;
            primaryContact.FirstName = "Mary";
            primaryContact.LastName = "Walter";
            primaryContact.CreatedBy = "System";
            primaryContact.CreatedOn = DateTime.Now;
            primaryContact.ModifiedBy = "System";
            primaryContact.ModifiedOn = DateTime.Now;
            primaryContact.Party = vendor;

            vendor.PrimaryContact = primaryContact;

            _context.Vendors.Add(vendor);

            return vendor;
        }
Ejemplo n.º 4
0
 public ActionResult AddVendor(Models.ViewModels.Purchases.AddVendor model)
 {
     var vendor = new Vendor()
     {
         Name = model.VendorName,
         AccountsPayableAccountId = model.AccountsPayableAccountId.Value == -1 ? null : model.AccountsPayableAccountId,
         PurchaseAccountId = model.PurchaseAccountId.Value == -1 ? null : model.PurchaseAccountId,
         PurchaseDiscountAccountId = model.PurchaseDiscountAccountId.Value == -1 ? null : model.PurchaseDiscountAccountId,
         CreatedBy = User.Identity.Name,
         CreatedOn = DateTime.Now,
         ModifiedBy = User.Identity.Name,
         ModifiedOn = DateTime.Now
     };
     _purchasingService.AddVendor(vendor);
     return RedirectToAction("Vendors");
 }
Ejemplo n.º 5
0
 public void UpdateVendor(Vendor vendor)
 {
     _vendorRepo.Update(vendor);
 }
Ejemplo n.º 6
0
        public void AddVendor(Vendor vendor)
        {
            vendor.AccountsPayableAccountId = _accountRepo.Table.Where(a => a.AccountCode == "20110").FirstOrDefault().Id;
            vendor.PurchaseAccountId = _accountRepo.Table.Where(a => a.AccountCode == "50200").FirstOrDefault().Id;
            vendor.PurchaseDiscountAccountId = _accountRepo.Table.Where(a => a.AccountCode == "50400").FirstOrDefault().Id;

            vendor.IsActive = true;

            _vendorRepo.Insert(vendor);
        }
Ejemplo n.º 7
0
 public void AddVendor(Vendor vendor)
 {
     _vendorRepo.Insert(vendor);
 }