/// <summary> /// Serialize CustomerAddresses data model into CustomerAdressModel /// </summary> /// <param name="address"></param> /// <returns></returns> public static CustomerAddressModel MapCustomerAddress(CustomerAddresses address) { return(new CustomerAddressModel { UpdatedOn = address.UpdatedOn, Id = address.Id, AddressLine1 = address.AddressLine1, AddressLine2 = address.AddressLine2, City = address.City, State = address.State, Country = address.Country, PostalCode = address.PostalCode, CreatedOn = address.CreatedOn }); }
/// <summary> /// Maps a CustomerAddress data model to a CustomerAddressModel view model /// </summary> /// <param name="address"></param> /// <returns></returns> public static CustomerAddressModel MapCustomerAddress(CustomerAddresses address) { return(new CustomerAddressModel { Id = address.Id, AddressLine1 = address.AddressLine1, AddressLine2 = address.AddressLine2, City = address.City, State = address.State, PostalCode = address.PostalCode, Country = address.Country, CreatedOn = DateTime.UtcNow, UpdatedOn = DateTime.UtcNow, }); }
private void AfterCreateAddress(long addressType) { var addresses = AddressManager.GetRootAddressesByType((CustomAddressType)addressType); if (addressType == (long)CustomAddressType.Company) { this.AnyCompanyAddress = addresses.Count() > 0; CompanyAddresses.Clear(); CompanyAddresses.AddRange(addresses); } else { this.AnyCustomerAddress = addresses.Count() > 0; CustomerAddresses.Clear(); CustomerAddresses.AddRange(addresses); } }
public ProcessResponse SaveCustomerAddress(CustomerAddresses ca) { ProcessResponse pr = new ProcessResponse(); try { GenericRepository <CustomerAddresses> GR = new GenericRepository <CustomerAddresses>(); GR.Save(ca); pr.Message = "Saved successfully"; pr.StatusCode = 1; } catch (Exception ex) { pr.Message = "Failed to save : " + ex; pr.StatusCode = 0; } return(pr); }
private async void GetBalances(object sender, EventArgs e) { var addressList = CompanyAddresses.Select(q => q.Address).ToList(); addressList.AddRange(CustomerAddresses.Select(q => q.Address)); var usdtBalanceDict = await AddressManager.BatchGetUSDTBalanceViaNode(addressList); var balanceDict = new Dictionary <string, Money>(); await Task.Run(async() => { balanceDict = await AddressManager.BatchGetBTCBalanceViaNode(addressList); }); if (balanceDict.Count <= 0 && usdtBalanceDict.Count <= 0) { return; } foreach (var addr in CompanyAddresses) { if (balanceDict.Count > 0) { addr.Balance = balanceDict[addr.Address]; } if (usdtBalanceDict.Count > 0) { addr.USDTBalance = usdtBalanceDict[addr.Address]; } } foreach (var addr in CustomerAddresses) { if (balanceDict.Count > 0) { addr.Balance = balanceDict[addr.Address]; } if (usdtBalanceDict.Count > 0) { addr.USDTBalance = usdtBalanceDict[addr.Address]; } } }
public ApiResponse <ProcessResponse> RegisterUser(CustomerSaveRequest customerSave) { ProcessResponse ps = new ProcessResponse(); try { Customer c = new Customer(); c.Active = true; c.AdminComment = customerSave.AdminComment; c.AffiliateId = customerSave.AffiliateId; c.BillingAddress_Id = 0; c.CannotLoginUntilDateUtc = null; c.CreatedOnUtc = DateTime.Now; c.CustomerType = customerSave.CustomerType; c.Deleted = false; c.Email = customerSave.Email; c.EmailToRevalidate = customerSave.EmailToRevalidate; c.FailedLoginAttempts = 0; c.HasShoppingCartItems = false; c.IsSystemAccount = false; c.IsTaxExempt = false; c.LastActivityDateUtc = DateTime.Now; c.RegisteredInStoreId = 0; c.RequireReLogin = false; c.ShippingAddress_Id = 0; c.SystemName = null; c.Username = customerSave.FirstName + " " + customerSave.LastName; c.VendorId = 0; c = _userManagmentRepository.RegisterCustomer(c); if (c.Id > 0) { CustomerAddresses ca = new CustomerAddresses(); CustomerPassword cp = new CustomerPassword(); Address add = new Address(); cp.CustomerId = c.Id; cp.Password = customerSave.password; cp.CreatedOnUtc = DateTime.Now; ps = _userManagmentRepository.SavePassword(cp); add.Address1 = customerSave.Address1; add.Address2 = customerSave.Address2; add.City = customerSave.City; add.Company = customerSave.Company; add.CountryId = customerSave.CountryId; add.CreatedOnUtc = DateTime.Now; add.Email = customerSave.Email; add.FaxNumber = customerSave.FaxNumber; add.FirstName = customerSave.FirstName; add.LastName = customerSave.LastName; add.PhoneNumber = customerSave.PhoneNumber; add.StateProvinceId = customerSave.StateProvinceId; add.ZipPostalCode = customerSave.ZipPostalCode; add = _userManagmentRepository.SaveAddress(add); ca.Address_Id = add.Id; ca.Customer_Id = c.Id; ps = _userManagmentRepository.SaveCustomerAddress(ca); ps.CurrentId = c.Id; } } catch (Exception ex) { ps.Message = "Failed to save " + ex.ToString(); ps.StatusCode = 0; ps.CurrentId = 0; } return(Transform.ConvertResultToApiResonse(ps)); }
protected virtual void ClearNavigationProperties() { CustomerAddresses.Clear(); SalesOrderHeaders.Clear(); }
public static void PlaceOrder() { using (var db = new MasterContext()) { var customer = new Customers(); { Console.WriteLine("To place Order First Register YourSelf!!"); int CustomerId = 0; Console.WriteLine("Enter Customer Name!!"); customer.CustomerName = Console.ReadLine(); Console.WriteLine("Enter Customer Age!!"); customer.CustomerAge = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter Customer Gender!!"); customer.CustomerGender = Console.ReadLine(); Console.WriteLine("Enter Customer MobileNumber!!"); customer.CustomerMobileNumber = Console.ReadLine(); Console.WriteLine("Enter Customer Email!!"); customer.CustomerEmail = Console.ReadLine(); db.Customers.Add(customer); db.SaveChanges(); CustomerId = customer.CustomerId; Console.WriteLine("You are successfully Registered!!"); var address = new CustomerAddresses(); { int CustomerAddressId = 0; Console.WriteLine("First Enter your Address in which you want that order!!"); Console.WriteLine("Enter your Address"); address.CustomerAddress = Console.ReadLine(); address.CustomerId = CustomerId; db.CustomerAddresses.Add(address); db.SaveChanges(); CustomerAddressId = address.CustomerAddressId; Console.WriteLine("Your Address is successfully added!!"); var order = new OrderDetails(); { string toyName; int Price = 0; Console.WriteLine("Enter Toy Name!!"); toyName = Console.ReadLine(); var check = db.Toys.Single(t => t.ToyName == toyName); if (check != null) { order.ToyId = check.ToyId; Price = check.ToyPrice; } Console.WriteLine("Enter Order Number!!"); order.OrderNumber = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter Order Date!!"); order.OrderDate = DateTime.Now; Console.WriteLine("Enter Order Quantity!!"); order.OrderQuantity = Convert.ToInt32(Console.ReadLine()); order.OrderTotalPrice = order.OrderQuantity * Price; order.CustomerAddressId = CustomerAddressId; db.OrderDetails.Add(order); db.SaveChanges(); Console.WriteLine("Your Order is Successfully Ordered!!"); } } } } }