public ActionResult addAddress(string id) { string[] customerData = HexSerialization.HexToString(id).Split('|'); ViewBag.customer = id; ViewBag.cardCode = customerData[0]; ViewBag.cardName = customerData[1]; BusinessPartnerAddressViewModel address = new BusinessPartnerAddressViewModel(); return View(address); }
public ActionResult addAddress(string id, BusinessPartnerAddressViewModel customerAddress) { #region User identification IIdentity context = HttpContext.User.Identity; bool admin = false; bool customerCreator = false; bool purchaseOrderCreator = false; int companyId = 0; string userName = ""; AppConnData appConnData = new AppConnData(); if (context.IsAuthenticated) { System.Web.Security.FormsIdentity ci = (System.Web.Security.FormsIdentity)HttpContext.User.Identity; string[] userRole = ci.Ticket.UserData.Split('|'); admin = int.Parse(userRole[1]) == 1 ? true : false; customerCreator = int.Parse(userRole[2]) == 1 ? true : false; purchaseOrderCreator = int.Parse(userRole[3]) == 1 ? true : false; companyId = int.Parse(userRole[4]); userName = ci.Name; appConnData = GetAppConnData(companyId); } #endregion string[] customerData = HexSerialization.HexToString(id).Split('|'); try { customerAddress.cardCode = customerData[0]; BusinessPartnerAddress customer = new BusinessPartnerAddress() { addressType = customerAddress.addType == "S" ? AddressType.ShipTo : AddressType.BillTo, address = customerAddress.address, city = customerAddress.city, street = customerAddress.street, zipCode = customerAddress.zipCode, country = customerAddress.country, county = customerAddress.county, streetNo = customerAddress.streetNo, taxCode = customerAddress.taxCode, cardCode = customerData[0], state = customerAddress.state, UserDefinedFields = new List<UserDefinedField>() }; customer.UserDefinedFields.Add(new UserDefinedField() { name = "U_CSS_IVA", type = UdfType.Alphanumeric, value = customerAddress.uCssIva }); backEnd.AddBusinessPartnerAddress(customer, appConnData); } catch (FaultException<DataAccessFault> ex) { ViewBag.mensaje = string.Format("Codigo {0} error:{1} {2}", ex.Code, ex.Detail.Description, ex.Message); return View(customerAddress); } return RedirectToAction("addAddress", new { id = id }); }