public void DeleteById(int Id) { ADDRESSINFO addr = new ADDRESSINFO() { ID = Id }; }
public void Save(bool fromPage) { if (IsValid()) { ADDRESS addr = GetAddress(); string operation = String.Empty; try { // not a new address if (AddrID != 0) { addr.ID = AddrID; if (!DisableOriginal) { ApplicationContext.Current.Customers.UpdateAddress(addr); } else { ADDRESSINFO addrInfo = new ADDRESSINFO(addr); ApplicationContext.Current.Orders.UpdateAddress(addrInfo); } operation = "updated"; } else { ApplicationContext.Current.Customers.InsertAddress(addr); operation = "inserted"; AddrID = addr.ID; } loadAddress(addr); if (!InOrder) { lnkDelAddr.Visible = true; imgDelete.Visible = true; imgSeparator.Visible = true; } if (Saving != null) { Saving(null, null); } ChangeSelectedPanel(0); } catch (Exception ex) { BasePage.Log(ex, ex.Message, ex.StackTrace, "CustomerAddressControl.Save"); writeError(ex.Message); } } else { Page.Validate(UniqueValidationGroup); } }
public void ReloadControl(bool PageLoad) { ADDRESS addr = null; if (AddrID != 0) { if (!DisableOriginal) { addr = ApplicationContext.Current.Customers.GetAddressById(AddrID); } else { ADDRESSINFO a = ApplicationContext.Current.Orders.GetAddress(AddrID); addr = new ADDRESS(a); } loadAddress(addr); if (!InOrder) { lnkDelAddr.Visible = true; imgDelete.Visible = true; imgSeparator.Visible = true; } } if (PageLoad) { // viewstate of dropdown is enabled, so there is no need to reload it on every postback LoadDDLs(addr == null ? null : addr.City, addr == null ? null : addr.TypeID); } else { // ddl already loaded, the values must be re-set if (addr != null && addr.City.HasValue) { ddlCities.SelectedValue = addr.City.Value.ToString(); } if (addr != null && addr.TypeID.HasValue) { ddlAddrType.SelectedValue = addr.TypeID.Value.ToString(); } } }
public void Delete(ADDRESSINFO Entity) { Context.ADDRESSINFO.Attach(Entity); Context.ADDRESSINFO.DeleteObject(Entity); }
public void Update(ADDRESSINFO Entity) { Context.ADDRESSINFO.Attach(Entity); Context.ObjectStateManager.ChangeObjectState(Entity, System.Data.EntityState.Modified); }
public void Insert(ADDRESSINFO Entity) { Context.ADDRESSINFO.AddObject(Entity); }
public List <ADDRESSINFO> Search(ADDRESSINFO Entity, int PageSize, int PageIndex, out int TotalRecords, string OrderExp, Util.SortDirection SortDirection) { throw new NotImplementedException(); }
protected void saveEasyPayOrder(EasyPayData data, List <SHOPPING_CART> carts, string originalResponse, decimal charge) { if (carts != null && carts.Count > 0) { int addrId, bonId = 0; decimal bonusUsed = 0; if (Session["AddrForEasyPay"] != null) { addrId = (int)Session["AddrForEasyPay"]; } else { BasePage.Log(null, "EasyPay save - null address.", "", "EasyPay.saveOrder"); } CultureInfo ci = new CultureInfo("en-US"); string cartID = data.OrderId; decimal total = ApplicationContext.Current.Carts.GetShoppingCartTotalAmount(cartID).Value; ORDERS order = new ORDERS(); int addrID = 0; // Bonus has been used decimal rate = ApplicationContext.Current.Payments.GetLastConversionRate().CurrencyRate + Configuration.CurrencyDelta; decimal amount = data.Amount / rate; if (total != amount) { if (Session["BonForEasyPay"] != null && Session["BonIdForEasyPay"] != null && !String.IsNullOrWhiteSpace(Session["BonIdForEasyPay"].ToString())) { bonusUsed = (decimal)Session["BonForEasyPay"]; bonId = (int)Session["BonIdForEasyPay"]; } if (bonusUsed == total - amount) { setBonus(order, bonId, bonusUsed); } else { BasePage.Log(null, "EasyPay order save - bonus MANIPULATION. Original:" + (total - amount) + " new: " + bonusUsed + " - txnID: " + data.TransactionId, "", "EasyPay order save"); return; } } order.TotalAmount = total; order.AmountPaid = amount; order.Verified = false; order.Canceled = false; order.Completed = true; order.Status = 1; try { order.CustomerID = carts.First().CustomerID; order.PAYMENT = new PAYMENT() { Type = 3 }; originalResponse = originalResponse.Replace("&", "\n"); order.PAYMENT.EASYPAY_PAYMENT = new EASYPAY_PAYMENT() { Amount = data.Amount, MerchantUsername = Configuration.EasyPayMerchantUser, TransactionID = data.TransactionId, ResponseCode = data.ErrorCode, Rate = rate, OriginalResponse = originalResponse, TransactionStatus = data.ErrorCodeS, Date = DateTime.Now, Fee = charge }; // TODO for now it is set to carrier without a fee order.ShippingID = 3; order.DateCreated = DateTime.Now; ADDRESS addr = ApplicationContext.Current.Customers.GetAddressById(addrID); // addresses if (addr != null) { ADDRESSINFO shipping = new ADDRESSINFO(addr); order.ADDRESSINFO = shipping; } //inserting and not saving as the saving will be done in the details insertion ApplicationContext.Current.Orders.Insert(order, true, false); // inserting the products of this order ApplicationContext.Current.Orders.InsertDetailsFromCart(order, carts, false); List <ORDER_DETAIL> details = ApplicationContext.Current.Orders.GetDetails(order.ID); CUSTOMER customer = ApplicationContext.Current.Customers.GetById(carts[0].CustomerID); Thread thread = new Thread(() => BasePage.sendOrderMailToAdmins(details, "EasyPay", "EasyPay Order", order.TotalAmount, customer.Name + " " + customer.Surname)); thread.Start(); Thread thread2 = new Thread(() => BasePage.sendOrderMailToCustomer(customer, details, "Porosia ne FZone.al")); thread2.Start(); lblResult.Text = "<b>" + Resources.Lang.PayPalThankyouLabel + "</b> <br/><br/>" + Resources.Lang.SaveTransactionID + "<b>" + data.TransactionId + "</b>"; } catch (System.Threading.ThreadAbortException ex) { } catch (Exception e) { //TODO log exception BasePage.Log(e, e.Message, e.StackTrace, "easyPay.Save"); lblResult.Text = Resources.Lang.PaymentProblemLiteral + "</b> <br/><br/>" + Resources.Lang.SaveTransactionID + "<b>" + data.TransactionId + "</b>";; } } }
private void saveOrder() { ORDERS order = new ORDERS(); order.TotalAmount = TotalAmount.Value + ShipCost; order.BonusUsed = 0; order.AmountPaid = TotalOrder; order.Verified = false; order.Canceled = false; order.Completed = false; order.Status = 1; string paymentType = String.Empty; int i; try { order.CustomerID = CurrentCustomer.Id; if (Int32.TryParse(selectedPayment.Value, out i)) { if (i == 3 || i == 4) { order.PAYMENT = new PAYMENT() { Type = (int)PaymentType.CA }; order.PAYMENT.CASH_PAYMENT = new CASH_PAYMENT() { Amount = TotalOrder }; if (i == 3) { order.PAYMENT.CASH_PAYMENT.Comments = txtCashComments.Text; order.PAYMENT.CASH_PAYMENT.Receiver = "Korrier"; //TODO paid date order.ShippingID = 3; paymentType = "Korrier"; } else { order.PAYMENT.CASH_PAYMENT.Receiver = "Zyra"; order.ShippingID = 1; paymentType = "Zyra"; } } } if ((ddlShippingAddress.SelectedValue == "0" || ddlShippingAddress.Items.Count == 0) && i == 3) { writeResult(Resources.Lang.SpecifyShippingAddress); radioBtnCarrier.Checked = true; divConfirmLink.Visible = true; return; } // setting used bonuses in the order object setBonus(order); order.DateCreated = DateTime.Now; if (i == 3) { // addresses ADDRESSINFO shipping = new ADDRESSINFO(address1.GetAddress()); //ADDRESSINFO billing = new ADDRESSINFO(address2.GetAddress()); order.ADDRESSINFO = shipping; //order.ADDRESSINFO1 = billing; } //inserting and not saving if there are any details, as the saving will be done in the details insertion ApplicationContext.Current.Orders.Insert(order, true, false); // inserting the products of this order List <SHOPPING_CART> carts = ApplicationContext.Current.Carts.GetShoppingCartItems(CartSession.First().Id); ApplicationContext.Current.Orders.InsertDetailsFromCart(order, carts, false); List <ORDER_DETAIL> details = ApplicationContext.Current.Orders.GetDetails(order.ID); Thread thread = new Thread(() => sendOrderMailToAdmins(details, paymentType, txtCashComments.Text, TotalOrder, CurrentCustomer.FullName)); thread.Start(); CUSTOMER customer = ApplicationContext.Current.Customers.GetByEmail(User.Identity.Name); Thread thread2 = new Thread(() => sendOrderMailToCustomer(customer, details, "Porosia ne FZone.al")); thread2.Start(); CartSession = null; Response.Redirect("/personal/orderDet/" + FashionZone.BL.Util.Encryption.Encrypt(order.ID.ToString())); } catch (System.Threading.ThreadAbortException ex) { } catch (Exception e) { //TODO log exception Log(e, e.Message, e.StackTrace, "Checkout.Save"); writeResult(Resources.Lang.ErrorVerifiedLabel); } }
protected void savePayPalOrder(PDTData data, List <SHOPPING_CART> carts, string originalResponse) { CultureInfo ci = new CultureInfo("en-US"); string cartID = data.Invoice; if (carts != null && carts.Count > 0) { decimal total = ApplicationContext.Current.Carts.GetShoppingCartTotalAmount(cartID).Value; ORDERS order = new ORDERS(); int addrID = 0; // Bonus has been used if (total != data.GrossTotal) { string[] custom = data.Custom.Split('-'); if (custom.Length == 3) { decimal bonus = Convert.ToDecimal(custom[2], ci); int bonusID = Convert.ToInt32(custom[1]); addrID = Convert.ToInt32(custom[0]); if (bonus == total - data.GrossTotal) { setBonus(order, bonusID, bonus); } else { BasePage.Log(null, "IPN order save - bonus MANIPULATION. Original:" + (total - data.GrossTotal) + " new: " + bonus + " - txnID: " + data.TransactionId, "", "IPN Handler"); return; } } } else { addrID = Convert.ToInt32(data.Custom); } order.TotalAmount = total; order.AmountPaid = data.GrossTotal; order.Verified = false; order.Canceled = false; if (data.PaymentStatus.ToUpper() == "COMPLETED") { order.Completed = true; } else { order.Completed = false; } order.Status = 1; try { order.CustomerID = carts.First().CustomerID; order.PAYMENT = new PAYMENT() { Type = 2 }; order.PAYMENT.PAYPAL_PAYMENT = new PAYPAL_PAYMENT() { Amount = data.GrossTotal, CartID = cartID, PaidOn = DateTime.Now, Currency = data.Currency, Fee = data.Fee, PayerEmail = data.PayerEmail, TransactionKey = data.TransactionId, PayerName = data.PayerFirstName + " " + data.PayerLastName, PaypalEmail = data.ReceiverEmail, Response = originalResponse, TransactionStatus = data.PaymentStatus, PayerStatus = data.PayerStatus }; // for now it is set to carrier without a fee order.ShippingID = 3; order.DateCreated = DateTime.Now; ADDRESS addr = ApplicationContext.Current.Customers.GetAddressById(addrID); // addresses if (addr != null) { ADDRESSINFO shipping = new ADDRESSINFO(addr); order.ADDRESSINFO = shipping; } //inserting and not saving as the saving will be done in the details insertion ApplicationContext.Current.Orders.Insert(order, true, false); // inserting the products of this order ApplicationContext.Current.Orders.InsertDetailsFromCart(order, carts, false); List <ORDER_DETAIL> details = ApplicationContext.Current.Orders.GetDetails(order.ID); CUSTOMER customer = ApplicationContext.Current.Customers.GetById(carts[0].CustomerID); Thread thread = new Thread(() => BasePage.sendOrderMailToAdmins(details, "PayPal", "PayPal Order", order.TotalAmount, customer.Name + " " + customer.Surname)); thread.Start(); Thread thread2 = new Thread(() => BasePage.sendOrderMailToCustomer(customer, details, "Porosia ne FZone.al")); thread2.Start(); } catch (System.Threading.ThreadAbortException ex) { } catch (Exception e) { //TODO log exception BasePage.Log(e, e.Message, e.StackTrace, "paypalSuccess.Save"); } } }
public void Save(bool fromPage) { if (IsValid()) { ADDRESS addr = GetAddress(); string operation = String.Empty; try { // not a new address if (AddrID != 0) { addr.ID = AddrID; if (!DisableOriginal) { ApplicationContext.Current.Customers.UpdateAddress(addr); } else { ADDRESSINFO addrInfo = new ADDRESSINFO(addr); ApplicationContext.Current.Orders.UpdateAddress(addrInfo); } operation = "updated"; } else { ApplicationContext.Current.Customers.InsertAddress(addr); operation = "inserted"; AddrID = addr.ID; } loadAddress(addr); if (!fromPage) { lblErrors.Visible = true; lblErrors.ForeColor = Color.Green; lblErrors.Text = "Address " + operation + " correctly."; } else { lblErrors.Visible = false; } if (!InOrder) { lnkDelAddr.Visible = true; } if (Saving != null) { Saving(null, null); } ChangeSelectedPanel(0); } catch (Exception ex) { writeError(ex.Message); } } else { Page.Validate(UniqueValidationGroup); writeError("Address could not be saved because some required fields are missing. "); } }
public void DeleteAddress(ADDRESSINFO Address) { _addressInfoDAO.Delete(Address); Context.SaveChanges(); }
public void InsertAddress(ADDRESSINFO Address) { _addressInfoDAO.Insert(Address); Context.SaveChanges(); }