コード例 #1
0
ファイル: SalesController.cs プロジェクト: aiampogi/accountgo
 public ActionResult AddCustomer(Models.ViewModels.Sales.AddCustomer model)
 {
     var customer = new Customer()
     {
         Name = model.Name,
         CreatedBy = User.Identity.Name,
         CreatedOn = DateTime.Now,
         ModifiedBy = User.Identity.Name,
         ModifiedOn = DateTime.Now,
     };
     _salesService.AddCustomer(customer);
     return RedirectToAction("EditCustomer", new { id = customer.Id });
 }
コード例 #2
0
        public ActionResult AddOrEditCustomer(Models.ViewModels.Sales.EditCustomer model)
        {
            Customer customer = null;
            if (model.Id != 0)
            {
                customer = _salesService.GetCustomerById(model.Id);                
            }
            else
            {
                customer = new Customer();
                customer.CreatedBy = User.Identity.Name;
                customer.CreatedOn = DateTime.Now;
            }

            customer.ModifiedBy = User.Identity.Name;
            customer.ModifiedOn = DateTime.Now;
            customer.Name = model.Name;
            if (model.PrimaryContactId != -1) customer.PrimaryContactId = model.PrimaryContactId;
            customer.AccountsReceivableAccountId = model.AccountsReceivableAccountId.Value == -1 ? null : model.AccountsReceivableAccountId;
            customer.SalesAccountId = model.SalesAccountId.Value == -1 ? null : model.SalesAccountId;
            customer.SalesDiscountAccountId = model.SalesDiscountAccountId.Value == -1 ? null : model.SalesDiscountAccountId;
            customer.PromptPaymentDiscountAccountId = model.PromptPaymentDiscountAccountId.Value == -1 ? null : model.PromptPaymentDiscountAccountId;

            if (model.Id != 0)
                _salesService.UpdateCustomer(customer);
            else
                _salesService.AddCustomer(customer);

            return RedirectToAction("Customers");
        }
コード例 #3
0
 public ActionResult AddCustomer(Models.ViewModels.Sales.AddCustomer model)
 {
     var customer = new Customer()
     {
         Name = model.Name,
     };
     _salesService.AddCustomer(customer);
     return RedirectToAction("EditCustomer", new { id = customer.Id });
 }
コード例 #4
0
ファイル: SalesController.cs プロジェクト: jontacky/accountgo
        public IActionResult SaveCustomer([FromBody] Dto.Sales.Customer customerDto)
        {
            bool isNew = customerDto.Id == 0;

            Core.Domain.Sales.Customer customer = null;

            if (isNew)
            {
                customer = new Core.Domain.Sales.Customer();

                customer.Party = new Core.Domain.Party()
                {
                    PartyType = Core.Domain.PartyTypes.Customer,
                };

                customer.PrimaryContact = new Core.Domain.Contact()
                {
                    ContactType = Core.Domain.ContactTypes.Customer,
                    Party       = new Core.Domain.Party()
                    {
                        PartyType = Core.Domain.PartyTypes.Contact
                    }
                };
            }
            else
            {
                customer = _salesService.GetCustomerById(customerDto.Id);
            }

            customer.No                           = customerDto.No;
            customer.Party.Name                   = customerDto.Name;
            customer.Party.Phone                  = customerDto.Phone;
            customer.Party.Email                  = customerDto.Email;
            customer.Party.Fax                    = customerDto.Fax;
            customer.Party.Website                = customerDto.Website;
            customer.PrimaryContact.FirstName     = customerDto.PrimaryContact.FirstName;
            customer.PrimaryContact.LastName      = customerDto.PrimaryContact.LastName;
            customer.PrimaryContact.Party.Name    = customerDto.PrimaryContact.Party.Name;
            customer.PrimaryContact.Party.Phone   = customerDto.PrimaryContact.Party.Phone;
            customer.PrimaryContact.Party.Email   = customerDto.PrimaryContact.Party.Email;
            customer.PrimaryContact.Party.Fax     = customerDto.PrimaryContact.Party.Fax;
            customer.PrimaryContact.Party.Website = customerDto.PrimaryContact.Party.Website;
            customer.AccountsReceivableAccountId  = customerDto.AccountsReceivableId;
            customer.SalesAccountId               = customerDto.SalesAccountId;
            customer.CustomerAdvancesAccountId    = customerDto.PrepaymentAccountId;
            customer.SalesDiscountAccountId       = customerDto.SalesDiscountAccountId;
            customer.PaymentTermId                = customerDto.PaymentTermId;
            customer.TaxGroupId                   = customerDto.TaxGroupId;
            customer.ModifiedBy                   = GetUserNameFromRequestHeader();

            if (isNew)
            {
                _salesService.AddCustomer(customer);
            }
            else
            {
                _salesService.UpdateCustomer(customer);
            }

            return(Ok());
        }