public HttpResponseMessage GetAllByType(int AddressType) { AddressBL blobj = new AddressBL(); var list = blobj.GetAddressesByType(AddressType); return(Request.CreateResponse(HttpStatusCode.OK, list)); }
/// <summary> /// Updates address /// </summary> /// <returns></returns> public static async Task UpdateAddress() { try { using (IAddressBL addressBL = new AddressBL()) { //Read Sl.No Write("Address #: "); bool isNumberValid = int.TryParse(ReadLine(), out int serial); if (isNumberValid) { serial--; RetailerBL retailerBL = new RetailerBL(); Retailer retailer = await retailerBL.GetRetailerByEmailBL(CommonData.CurrentUser.Email); List<Address> addresses = await addressBL.GetAddressByRetailerIDBL(retailer.RetailerID); if (serial <= addresses.Count - 1) { //Read inputs Address address = addresses[serial]; Write("Address Line 1: "); address.AddressLine1 = ReadLine(); Write("Address Line 2: "); address.AddressLine2 = ReadLine(); Write("LandMark: "); address.Landmark = ReadLine(); Write("City: "); address.City = ReadLine(); Write("State: "); address.State = ReadLine(); Write("PinCode: "); address.PinCode = ReadLine(); //Invoke UpdateAddressBL method to update bool isUpdated = await addressBL.UpdateAddressBL(address); if (isUpdated) { WriteLine("Address Updated"); } } else { WriteLine($"Invalid Address #.\nPlease enter a number between 1 to {addresses.Count}"); } } else { WriteLine($"Invalid number."); } } } catch (Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }
public static async Task UpdateAddress() { try { using (IAddressBL addressBL = new AddressBL()) { Write("Address #: "); bool isNumberValid = int.TryParse(ReadLine(), out int number); if (isNumberValid) { number--; CustomerBL customerBL = new CustomerBL(); Customer customer = await customerBL.GetCustomerByEmailBL(UserData.CurrentUser.Email); List <Address> addresses = await addressBL.GetAddressByCustomerIDBL(customer.CustomerID); if (number <= addresses.Count - 1) { Address address = addresses[number]; Write("Address Line 1: "); address.AddressLine1 = ReadLine(); Write("Address Line 2: "); address.AddressLine2 = ReadLine(); Write("LandMark: "); address.Landmark = ReadLine(); Write("City: "); address.City = ReadLine(); Write("State: "); address.State = ReadLine(); Write("PinCode: "); address.PinCode = ReadLine(); bool isUpdated = await addressBL.UpdateAddressBL(address); if (isUpdated) { WriteLine("Address Updated"); } } else { WriteLine($"Invalid Address #.\nPlease enter a number between 1 to {addresses.Count}"); } } else { WriteLine($"Invalid number."); } } } catch (Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }
protected void BindDDLCities() { ddlCities.Items.Add("בחר עיר"); AddressBL abl = new AddressBL(); LinkedList <ListItem> l = abl.getAllCities(); foreach (ListItem li in l) { ddlCities.Items.Add(li); } }
/// <summary> /// Menu for Retailer Address User /// </summary> /// <returns></returns> public static async Task<int> AddressPresentationMenu() { int choice = -2; using (IAddressBL addressBL = new AddressBL()) { do { //Get and display list of system users. RetailerBL retailerBL = new RetailerBL(); Retailer retailer = await retailerBL.GetRetailerByEmailBL(CommonData.CurrentUser.Email); List<Address> addresses = await addressBL.GetAddressByRetailerIDBL(retailer.RetailerID); WriteLine("\n***************ADDRESS***********\n"); WriteLine("Addresses:"); if (addresses != null && addresses?.Count > 0) { WriteLine("#\tAddressLine 1\tLandMark\tCity\tState"); int serial = 0; foreach (var address in addresses) { serial++; WriteLine($"{serial}\t{address.AddressLine1}\t{address.Landmark}\t{address.City}\t{address.State}"); } } //Menu WriteLine("\n1.Add Address"); WriteLine("2. Update Existing Address"); WriteLine("3. Delete Existing Address"); WriteLine("0. Back"); WriteLine("-1. Exit"); Write("Choice: "); //Accept and check choice bool isValidChoice = int.TryParse(ReadLine(), out choice); if (isValidChoice) { switch (choice) { case 1: await AddAddress(); break; case 2: await UpdateAddress(); break; case 3: await DeleteAddress(); break; case 0: break; case -1: break; default: WriteLine("Invalid Choice"); break; } } else { choice = -2; } } while (choice != 0 && choice != -1); } return choice; }
/// <summary> /// Adds Address /// </summary> /// <returns></returns> public static async Task AddAddress() { try { //Read inputs Address address = new Address(); CustomerBL CustomerBL = new CustomerBL(); Customer Customer = await CustomerBL.GetCustomerByEmailBL(CommonData.CurrentUser.Email); address.CustomerID = Customer.CustomerID; Write("Address Line 1: "); address.AddressLine1 = ReadLine(); Write("Address Line 2: "); address.AddressLine2 = ReadLine(); Write("LandMark: "); address.Landmark = ReadLine(); Write("City: "); address.City = ReadLine(); Write("State: "); address.State = ReadLine(); Write("PinCode: "); address.PinCode = ReadLine(); //Invoke AddAddressBL method to add using (AddressBL addressBL = new AddressBL()) { bool isAdded = await addressBL.AddAddressBL(address); if (isAdded) { WriteLine("Address Added"); } WriteLine("Do you want to serailize:Y/N"); string confirmation = ReadLine(); if (confirmation.Equals("Y", StringComparison.OrdinalIgnoreCase)) { addressBL.Serialize(); } } } catch (System.Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }
/// <summary> /// Delete Address. /// </summary> /// <returns></returns> public static async Task DeleteAddress() { try { using (IAddressBL addressBL = new AddressBL()) { //Read Sl.No Write("Address #: "); bool isNumberValid = int.TryParse(ReadLine(), out int serial); if (isNumberValid) { serial--; RetailerBL retailerBL = new RetailerBL(); Retailer retailer = await retailerBL.GetRetailerByEmailBL(CommonData.CurrentUser.Email); List<Address> addresses = await addressBL.GetAddressByRetailerIDBL(retailer.RetailerID); Write("Are you sure? (Y/N): "); string confirmation = ReadLine(); if (confirmation.Equals("Y", StringComparison.OrdinalIgnoreCase)) { if (serial <= addresses.Count - 1) { //Invoke DeleteSystemUserBL method to delete Address address = addresses[serial]; bool isDeleted = await addressBL.DeleteAddressBL(address.AddressID); if (isDeleted) { WriteLine("Retailer Address Deleted"); } } } } } } catch (Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }
protected void ddlCities_SelectedIndexChanged(object sender, EventArgs e) { if (ddlCities.SelectedItem.Text.CompareTo("בחר עיר") == 1) { ddlHood.Items.Clear(); ddlHood.Items.Add("בחר שכונה"); AddressBL abl = new AddressBL(); LinkedList <ListItem> l = abl.getAllHood(ddlCities.SelectedItem.Value); foreach (ListItem li in l) { ddlHood.Items.Add(li); } } else { ddlHood.Items.Clear(); } }
public static async Task DeleteAddress() { try { using (IAddressBL addressBL = new AddressBL()) { Write("Address #: "); bool isNumberValid = int.TryParse(ReadLine(), out int number); if (isNumberValid) { number--; CustomerBL customerBL = new CustomerBL(); Customer customer = await customerBL.GetCustomerByEmailBL(UserData.CurrentUser.Email); List <Address> addresses = await addressBL.GetAddressByCustomerIDBL(customer.CustomerID); Write("Are you sure? (Y/N): "); string confirmation = ReadLine(); if (confirmation.Equals("Y", StringComparison.OrdinalIgnoreCase)) { if (number <= addresses.Count - 1) { Address address = addresses[number]; bool isDeleted = await addressBL.DeleteAddressBL(address.AddressID); if (isDeleted) { WriteLine("Customer Address Deleted"); } } } } } } catch (Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }
public UserDataModel Update(UserDataModel dataModel) { if (dataModel != null) { UserDTO userDTO = new UserDTO(); UserAccountDTO userAccountDTO = new UserAccountDTO(); PhoneDTO phoneDTO = new PhoneDTO(); EmailDTO emailDTO = new EmailDTO(); AddressDTO addressDTO = new AddressDTO(); userDTO = UserDataModelAssembler.ToUserDTO(dataModel); userAccountDTO = UserDataModelAssembler.ToUserAccountDTO(dataModel); phoneDTO = UserDataModelAssembler.ToPhoneDTO(dataModel); emailDTO = UserDataModelAssembler.ToEmailDTO(dataModel); addressDTO = UserDataModelAssembler.ToAddressDTO(dataModel); if (userDTO != null) { userDTO = usersBL.Update(userDTO); } if (userAccountDTO != null) { userAccountDTO = AccountBL.Update(userAccountDTO); } if (phoneDTO != null) { phoneDTO = phonesBL.Update(phoneDTO); } if (emailDTO != null) { EmailsBL.Update(emailDTO); } if (addressDTO != null) { AddressBL.Update(addressDTO); } } return(dataModel); }
public static async Task AddAddress() { try { Address address = new Address(); CustomerBL customerBL = new CustomerBL(); Customer customer = await customerBL.GetCustomerByEmailBL(UserData.CurrentUser.Email); address.CustomerID = customer.CustomerID; Write("Address Line 1: "); address.AddressLine1 = ReadLine(); Write("Address Line 2: "); address.AddressLine2 = ReadLine(); Write("LandMark: "); address.Landmark = ReadLine(); Write("City: "); address.City = ReadLine(); Write("State: "); address.State = ReadLine(); Write("PinCode: "); address.PinCode = ReadLine(); using (AddressBL addressBL = new AddressBL()) { bool isAdded = await addressBL.AddAddressBL(address); if (isAdded) { WriteLine("Address Added"); } } } catch (Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }
public AdressController(DbXCART db) { this.bl = new AddressBL(db); }
/// <summary> /// Confirm Order /// </summary> /// <returns></returns> public static async Task ConfirmOrder() { try { IProductBL productBL = new ProductBL(); Guid tempOrderID; using (IOrderDetailBL orderDetailBL = new OrderDetailBL()) { CustomerBL CustomerBL = new CustomerBL(); Customer Customer = await CustomerBL.GetCustomerByEmailBL(CommonData.CurrentUser.Email); AddressBL addressBL = new AddressBL(); List <Address> addresses = await addressBL.GetAddressByCustomerIDBL(Customer.CustomerID); double totalamount = 0; int quantity = 0; Guid orderID = Guid.NewGuid(); tempOrderID = orderID; foreach (var cartProduct in cart) { OrderDetail orderDetail = new OrderDetail(); WriteLine("#\tAddressLine 1\tLandMark\tCity"); int serial = 0; foreach (var address in addresses) { serial++; WriteLine($"{serial}\t{address.AddressLine1}\t{address.Landmark}\t{address.City}"); } Write("Address #: "); bool isNumberValid = int.TryParse(ReadLine(), out int serial1); if (isNumberValid) { serial1--; if (serial1 <= addresses.Count - 1) { //Read inputs Address address = addresses[serial1]; orderDetail.AddressId = address.AddressID; } } orderDetail.OrderId = orderID; orderDetail.ProductID = cartProduct.ProductID; orderDetail.ProductPrice = cartProduct.ProductPrice; orderDetail.ProductQuantityOrdered = cartProduct.ProductQuantityOrdered; orderDetail.TotalAmount = (cartProduct.ProductPrice * cartProduct.ProductQuantityOrdered); totalamount += orderDetail.TotalAmount; quantity += orderDetail.ProductQuantityOrdered; bool isAdded; Guid newguid; (isAdded, newguid) = await orderDetailBL.AddOrderDetailsBL(orderDetail); } using (IOrderBL orderBL = new OrderBL()) { Order order = new Order(); order.OrderId = orderID; order.CustomerID = Customer.CustomerID; order.TotalQuantity = quantity; order.OrderAmount = totalamount; bool isAdded; Guid newguid; (isAdded, newguid) = await orderBL.AddOrderBL(order); if (isAdded) { WriteLine("Order Added"); } } } IOrderBL orderBL1 = new OrderBL(); Order order1 = await orderBL1.GetOrderByOrderIDBL(tempOrderID); WriteLine($"Your Order No. {order1.OrderNumber}\t{order1.TotalQuantity}\t{order1.OrderAmount}\t{order1.DateOfOrder}"); WriteLine("Order Details"); IOrderDetailBL orderDetailBL1 = new OrderDetailBL(); List <OrderDetail> orderDetailslist = await orderDetailBL1.GetOrderDetailsByOrderIDBL(tempOrderID); foreach (var item in orderDetailslist) { Product product = await productBL.GetProductByProductIDBL(item.ProductID); WriteLine($"{product.ProductName}\t{item.ProductPrice}\t{item.ProductQuantityOrdered}\t{item.TotalAmount}"); } cart.Clear(); } catch (System.Exception ex) { ExceptionLogger.LogException(ex); WriteLine(ex.Message); } }
protected void btnAddressSubmit_Click(object sender, EventArgs e) { try { AddressEntity.SAID = txtSAId.Text; AddressEntity.Type = 1; AddressEntity.UIC = "0"; AddressEntity.ReferenceSAID = Session["SAID"].ToString(); AddressEntity.HouseNo = txtHouseNo.Text; AddressEntity.BuildingName = txtBulding.Text; AddressEntity.Floor = txtFloor.Text; AddressEntity.FlatNo = txtFlatNo.Text; AddressEntity.RoadName = txtRoadName.Text; AddressEntity.RoadNo = txtRoadNo.Text.Trim(); AddressEntity.SuburbName = txtRoadNo.Text; AddressEntity.City = txtCity.Text; AddressEntity.Complex = txtComplex.Text; AddressEntity.PostalCode = txtPostalCode.Text; AddressEntity.Province = Convert.ToInt32(ddlProvince.SelectedValue); AddressEntity.Country = Convert.ToInt32(ddlCountry.SelectedValue); AddressEntity.AdvisorId = 0; AddressEntity.Status = 1; AddressEntity.CreatedBy = 0; int result; if (Convert.ToInt32(ViewState["Addressflag"]) == 1) { AddressEntity.AddressDetailID = Convert.ToInt32(ViewState["AddressDetailID"]); result = new AddressBL().InsertUpdateAddress(AddressEntity, 'u'); lblTitle.Text = "Thank You!"; lblTitle.ForeColor = System.Drawing.Color.Green; message.ForeColor = System.Drawing.Color.Green; message.Text = "Address details updated successfully!"; ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true); } else { result = new AddressBL().InsertUpdateAddress(AddressEntity, 'i'); lblTitle.Text = "Thank You!"; lblTitle.ForeColor = System.Drawing.Color.Green; message.Text = "Address details saved successfully!"; message.ForeColor = System.Drawing.Color.Green; ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true); clearAddresscontrols(); } if (result == 1) { clearAddresscontrols(); GetAddressDetails(); } else { lblTitle.Text = "Warning!"; lblTitle.ForeColor = System.Drawing.Color.Red; message.ForeColor = System.Drawing.Color.Red; message.Text = "Sorry, Please try again!"; ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true); clearAddresscontrols(); } } catch { lblTitle.Text = "Warning!"; lblTitle.ForeColor = System.Drawing.Color.Red; message.ForeColor = System.Drawing.Color.Red; message.Text = "Sorry, Something went wrong, please contact administrator"; ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true); } }
public static async Task <int> AddressPresentationMenu() { int choice = -2; using (IAddressBL addressBL = new AddressBL()) { do { CustomerBL customerBL = new CustomerBL(); Customer customer = await customerBL.GetCustomerByEmailBL(UserData.CurrentUser.Email); List <Address> addresses = await addressBL.GetAddressByCustomerIDBL(customer.CustomerID); WriteLine("\n***************ADDRESS***********\n"); WriteLine("Addresses:"); if (addresses != null && addresses.Count > 0) { WriteLine("#\tAddressLine 1\tLandMark\tCity\tState"); int count = 0; foreach (var address in addresses) { count++; WriteLine($"{count}\t{address.AddressLine1}\t{address.Landmark}\t{address.City}\t{address.State}"); } } WriteLine("\n1.Add Address"); WriteLine("2.Update Existing Address"); WriteLine("3.Delete Existing Address"); WriteLine("0.Back"); WriteLine("-1.Exit"); Write("Choice: "); bool isValidChoice = int.TryParse(ReadLine(), out choice); if (isValidChoice) { switch (choice) { case 1: await AddAddress(); break; case 2: await UpdateAddress(); break; case 3: await DeleteAddress(); break; case 0: break; case -1: break; default: WriteLine("Invalid Choice"); break; } } else { choice = -2; } } while (choice != 0 && choice != -1); } return(choice); }
public UserDataModel Create(UserDataModel dataModel) { if (dataModel != null) { UserDTO userDTO = new UserDTO(); UserAccountDTO userAccountDTO = new UserAccountDTO(); PhoneDTO phoneDTO = new PhoneDTO(); EmailDTO emailDTO = new EmailDTO(); AddressDTO addressDTO = new AddressDTO(); ExperienceDTO exprienceDTO = new ExperienceDTO(); AchievementDTO achievementDTO = new AchievementDTO(); EducationDTO educationDTO = new EducationDTO(); SkillDTO skillDTO = new SkillDTO(); LanguageDTO language = new LanguageDTO(); userDTO = UserDataModelAssembler.ToUserDTO(dataModel); userAccountDTO = UserDataModelAssembler.ToUserAccountDTO(dataModel); phoneDTO = UserDataModelAssembler.ToPhoneDTO(dataModel); emailDTO = UserDataModelAssembler.ToEmailDTO(dataModel); addressDTO = UserDataModelAssembler.ToAddressDTO(dataModel); if (userDTO != null) { userDTO = usersBL.Create(userDTO); } dataModel = UserDataModelAssembler.ToDataModel(userDTO, userAccountDTO, addressDTO, phoneDTO, emailDTO, null, null, null, null, null, null); userAccountDTO = UserDataModelAssembler.ToUserAccountDTO(dataModel); if (userAccountDTO != null) { userAccountDTO = AccountBL.Create(userAccountDTO); } addressDTO = UserDataModelAssembler.ToAddressDTO(dataModel); if (addressDTO != null) { addressDTO = AddressBL.Create(addressDTO); } dataModel = UserDataModelAssembler.ToDataModel(userDTO, userAccountDTO, addressDTO, phoneDTO, emailDTO, null, null, null, null, null, null); new UserAddressBL().Create(new UserAddressDTO() { UserID = dataModel.UserID, AddressID = dataModel.UserAddressID, IsPrimary = true }); dataModel = UserDataModelAssembler.ToDataModel(userDTO, userAccountDTO, addressDTO, phoneDTO, emailDTO, null, null, null, null, null, null); phoneDTO = UserDataModelAssembler.ToPhoneDTO(dataModel); if (phoneDTO != null) { phoneDTO.AddressbookID = addressDTO.AddressID; phoneDTO = phonesBL.Create(phoneDTO); } dataModel = UserDataModelAssembler.ToDataModel(userDTO, userAccountDTO, addressDTO, phoneDTO, emailDTO, null, null, null, null, null, null); new UserPhoneBL().Create(new UserPhoneDTO() { UserID = dataModel.UserID, PhoneID = dataModel.UserPhoneID, IsPrimary = true }); emailDTO = UserDataModelAssembler.ToEmailDTO(dataModel); if (emailDTO != null) { emailDTO = EmailsBL.Create(emailDTO); } dataModel = UserDataModelAssembler.ToDataModel(userDTO, userAccountDTO, addressDTO, phoneDTO, emailDTO, null, null, null, null, null, null); new UserEmailBL().Create(new UserEmailDTO() { UserID = dataModel.UserID, EmailID = dataModel.UserEmailID, IsPrimary = true }); } return(dataModel); }