public static void InsertCustomer(CustomerInsert model) { IEnumerable <CustomerGroup> customerGroups = new List <CustomerGroup>(); using (var client = new HttpClient()) { client.BaseAddress = new Uri(ECONOMIC_URL); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Add(Header_Name_AccessID, AccessID); client.DefaultRequestHeaders.Add(Header_Name_AppID, AppID); var formatters = new List <MediaTypeFormatter>() { new JsonMediaTypeFormatter(), new XmlMediaTypeFormatter() }; var responseTask = client.PostAsJsonAsync("/Customers", model); responseTask.Wait(); HttpResponseMessage response = responseTask.Result; if (!response.IsSuccessStatusCode) { var content = response.Content.ReadAsStringAsync(); content.Wait(); throw new Exception(string.Format("ErrorCode: {0} - Message: {1}", response.StatusCode, content.Result)); } } }
public IActionResult CreateCustomer(CustomerInsert Customer) { try { return(new JsonResult(CustomerBAL.CreateCustomer(Customer))); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, "Failed to create Customer")); } }
public Customer CreateCustomer(CustomerInsert customer) { using (SqlConnection connection = new SqlConnection(DefaultConnection)) { DynamicParameters p = new DynamicParameters(); p.Add("businessid", customer.BusinessID); p.Add("companyname", customer.CompanyName); p.Add("email", customer.Email); p.Add("apemail", customer.APEmail); p.Add("createdby", customer.CreatedBy); Customer result = connection.Query <Customer>("spCreateCustomer", p, commandType: CommandType.StoredProcedure).Single(); return(result); } }
public Customer CreateCustomer(CustomerInsert customer) { return(CustomerDAL.CreateCustomer(customer)); }
public ActionResult Signup(CustomerSignupViewModel profileModel) { TempData["successSignup"] = false; if (ModelState.IsValid) { OrderViewModel order = null; if (Session[WebshopSaleController.ORDER_SESSION] != null) { order = (OrderViewModel)Session[WebshopSaleController.ORDER_SESSION]; } else if (profileModel.IsProduct) { throw new Exception("Der opstod en uventet fejl under oprettelsen af ordren. Prøv igen."); } if (Members.GetByUsername(profileModel.Username) != null) { throw new Exception(string.Format("Brugernavn {0} er taget. Skriv et andet og prøv igen.", profileModel.Username)); } if (Members.GetByEmail(profileModel.Email) != null) { throw new Exception(string.Format("Email {0} er allerede brugt. Du har allerede en konto hos os.", profileModel.Email)); } MembershipCreateStatus status = AddCustomerToUmbraco(profileModel); if (status != MembershipCreateStatus.Success) { // // economic // var isEmailInEconomic = CustomerClient.GetCustomers().FirstOrDefault(c => c.Email.Equals(profileModel.Email)) != null; if (isEmailInEconomic) { throw new Exception(string.Format("Email {0} bliver allerede brugt i Kim Dam Developments regnskabssystem. Kontakt os for at få løst problemet.", profileModel.Email)); } var customer = new CustomerInsert(); customer.Name = !string.IsNullOrWhiteSpace(profileModel.CompanyName) ? profileModel.CompanyName : string.Format("{0} {1}", profileModel.FirstName, profileModel.LastName); customer.Address = profileModel.Address; customer.City = profileModel.City; customer.Zip = profileModel.Postcode; customer.CorporateIdentificationNumber = profileModel.CVRNumber; customer.Email = profileModel.Email; customer.TelephoneAndFaxNumber = profileModel.Phone; customer.Country = profileModel.Country; customer.County = profileModel.Country; customer.Currency = "DKK"; customer.PaymentTerms = new PaymentTerm() { PaymentTermsNumber = 4, Name = string.Empty, Self = "https://restapi.e-conomic.com/payment-terms/4" }; customer.VatZone = new VatZone() { VatZoneNumber = 1, Name = string.Empty, Self = "https://restapi.e-conomic.com/vat-zones/1" }; customer.Layout = new Layout() { LayoutNumber = 18, Name = string.Empty, Self = "https://restapi.e-conomic.com/layouts/10" }; customer.Barred = false; // economic insert CustomerClient.InsertCustomer(customer); if (order != null) { esUsersSoapClient client = null; var product = CustomerClient.GetProduct(order.AmountProduct.Product.ID); if (product.ProductType == ProductType.Webhotel) { client = new esUsersSoapClient(ESUSERSSOAP); client.ClientCredentials.UserName.UserName = WEBSITEPANEL_USERNAME; client.ClientCredentials.UserName.Password = WEBSITEPANEL_PASSWORD; client.Open(); var userInfo = new WebsitepanelService.UserInfo(); userInfo.Address = profileModel.Address; userInfo.City = profileModel.City; userInfo.FirstName = profileModel.FirstName; userInfo.LastName = profileModel.LastName; userInfo.Zip = profileModel.Postcode; userInfo.Email = profileModel.Email; userInfo.CompanyName = profileModel.CompanyName; userInfo.Comments = string.Format("CVR: {0}", profileModel.CVRNumber); var regex = new System.Text.RegularExpressions.Regex(@"([\w+\s*\.*]+\))"); foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) { RegionInfo region = new RegionInfo(ci.Name); var match = regex.Match(ci.EnglishName); string countryName = match.Value.Length == 0 ? "NA" : match.Value.Substring(0, match.Value.Length - 1); if (countryName == profileModel.Country) { userInfo.Country = region.TwoLetterISORegionName; break; } } userInfo.Changed = DateTime.Now; userInfo.Created = DateTime.Now; userInfo.EcommerceEnabled = false; userInfo.HtmlMail = true; userInfo.Role = WebsitepanelService.UserRole.User; userInfo.Status = WebsitepanelService.UserStatus.Pending; client.AddUser(userInfo, true, profileModel.Password); } else if (product.ProductType == ProductType.GameServer) { } } TempData["successSignup"] = true; } return(RedirectToCurrentUmbracoPage()); } return(CurrentUmbracoPage()); }