Пример #1
0
 public ActionResult Create(CustomerViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         try
         {
             var id = Guid.NewGuid();
             _customerService.Create(
                 id,
                 viewModel.Name,
                 viewModel.AssetLine,
                 Address.GetAddressFromLineDetails(viewModel.Address1, viewModel.Address2, viewModel.Address3, viewModel.Address4, viewModel.Address5),
                 ContactInfo.GetContactInfoFromDetails(viewModel.Telephone, viewModel.Fax, viewModel.Email, viewModel.Contact1, viewModel.Contact2),
                 viewModel.InvoiceTitle,
                 viewModel.InvoiceAddressSameAsMain ?
                 Address.GetAddressFromLineDetails(viewModel.Address1, viewModel.Address2, viewModel.Address3, viewModel.Address4, viewModel.Address5) :
                 Address.GetAddressFromLineDetails(viewModel.InvoiceAddress1, viewModel.InvoiceAddress2, viewModel.InvoiceAddress3, viewModel.InvoiceAddress4, viewModel.InvoiceAddress5),
                 ContactInfo.GetContactInfoFromDetails(viewModel.SalesTelephone, viewModel.SalesFax, viewModel.SalesEmail, viewModel.SalesContact1, viewModel.SalesContact2),
                 viewModel.DeliveryTitle,
                 viewModel.DeliveryAddressSameAsMain ?
                 Address.GetAddressFromLineDetails(viewModel.Address1, viewModel.Address2, viewModel.Address3, viewModel.Address4, viewModel.Address5) :
                 Address.GetDeliveryAddressFromLineDetails(viewModel.DeliveryAddress1, viewModel.DeliveryAddress2, viewModel.DeliveryAddress3, viewModel.DeliveryAddress4, viewModel.DeliveryAddress5, viewModel.DeliveryAddress6, viewModel.DeliveryAddress7),
                 ContactInfo.GetContactInfoFromDetails(viewModel.DeliveryTelephone, viewModel.DeliveryFax, viewModel.DeliveryEmail, viewModel.DeliveryContact1, viewModel.DeliveryContact2));
             return(RedirectToAction("Index"));
         }
         catch (DomainValidationException dex)
         {
             ModelState.UpdateFromDomain(dex.Result);
         }
     }
     return(View(viewModel));
 }
Пример #2
0
 public ActionResult Edit(SupplierViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _supplierService.Edit(
                 viewModel.Id,
                 viewModel.Name,
                 Address.GetAddressFromLineDetails(viewModel.Address1, viewModel.Address2, viewModel.Address3, viewModel.Address4, viewModel.Address5),
                 ContactInfo.GetContactInfoFromDetails(viewModel.Telephone, viewModel.Fax, viewModel.Email, viewModel.Contact1, viewModel.Contact2),
                 Address.GetAddressFromLineDetails(viewModel.SalesAddress1, viewModel.SalesAddress2, viewModel.SalesAddress3, viewModel.SalesAddress4, viewModel.SalesAddress5),
                 ContactInfo.GetContactInfoFromDetails(viewModel.SalesTelephone, viewModel.SalesFax, viewModel.SalesEmail, viewModel.SalesContact1, viewModel.SalesContact2));
             return(RedirectToAction("Index"));
         }
         catch (DomainValidationException dex)
         {
             ModelState.UpdateFromDomain(dex.Result);
         }
     }
     return(View(viewModel));
 }