コード例 #1
0
        public string[] CheckProductQuantities()
        {
            try
            {
                if (Context.User.IsInRole("User"))
                {
                    User myLoggedUser = new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name);
                    List<ShoppingCart> myShoppingCartItems = new ShoppingCartLogic().RetrieveAllShoppingCartItems(myLoggedUser.Id).ToList();

                    List<string> ViolatingIDs = new List<string>();

                    foreach (ShoppingCart myShoppingCartItem in myShoppingCartItems)
                    {
                        if (!new OrdersLogic().HasSufficientQuantity(myShoppingCartItem.ProductFK, myShoppingCartItem.Quantity))
                        {
                            ViolatingIDs.Add(myShoppingCartItem.ProductFK.ToString());
                        }
                    }

                    return ViolatingIDs.ToArray();
                }
                else
                {
                    return new string[] { "" };
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
コード例 #2
0
        public void AddToCart(string ProductID, string Quantity)
        {
            try
            {
                if (Context.User.IsInRole("User"))
                {
                    Guid myProductID = Guid.Parse(ProductID.Trim());
                    int myQuantity = 0;

                    User myLoggedUser = new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name);

                    if (Quantity.Trim() != string.Empty)
                    {
                        myQuantity = Convert.ToInt32(Quantity.Trim());
                    }
                    else
                    {
                        myQuantity = 1;
                    }

                    new ShoppingCartLogic().AddToCart(myLoggedUser.Id, myProductID, myQuantity);
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
コード例 #3
0
        public string LoadShoppingCartItems()
        {
            try
            {
                if (Context.User.IsInRole("User"))
                {
                    string HTML = "";

                    User myLoggedUser = new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name);
                    List<ShoppingCart> myShoppingCartItems = new ShoppingCartLogic().RetrieveAllShoppingCartItems(myLoggedUser.Id).ToList();
                    List<Product> myProductList = new List<Product>();

                    foreach (ShoppingCart myShoppingCartItem in myShoppingCartItems)
                    {
                        myProductList.Add(new ProductsLogic().RetrieveProductByID(myShoppingCartItem.ProductFK.ToString()));
                    }

                    Product[] myProducts = myProductList.ToArray();

                    if (myProducts.Length > 0)
                    {
                        for (int i = 1; i <= (myProducts.Length + 4 / 4); i++)
                        {
                            int Counter = i * 4;

                            HTML += "<tr>";

                            for (int j = (Counter - 3); j <= Counter; j++)
                            {
                                HTML += "<td>";

                                HTML += TDContents(myProducts[j - 1]);

                                HTML += "</td>";

                                if (j == myProducts.Length)
                                {
                                    goto LoopEnd;
                                }
                            }

                            HTML += "</tr>";
                        }
                    }

                LoopEnd:

                    return HTML;
                }
                else
                {
                    return "";
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
コード例 #4
0
 protected async void ResetPassword(object sender, EventArgs e)
 {
     UsersLogic UsersLogic = new UsersLogic();
     if (await UsersLogic.SendResetPasswordMail(emailtxt.Value))
     {
         Response.Redirect("~/account/forgotpassword?success=true", false);
     }
 }
コード例 #5
0
        public void CompleteCheckout(string CreditCard)
        {
            try
            {
                if (Context.User.IsInRole("User"))
                {
                    User myLoggedUser = new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name);
                    List<ShoppingCart> myShoppingCartItems = new ShoppingCartLogic().RetrieveAllShoppingCartItems(myLoggedUser.Id).ToList();
                    List<OrderItem> myOrderItems = new List<OrderItem>();

                    foreach (ShoppingCart myShoppingCartItem in myShoppingCartItems)
                    {
                        UserTypeProduct myPriceType = new PriceTypesLogic().RetrievePriceTypeByID(myLoggedUser.UserTypeFK, myShoppingCartItem.ProductFK);

                        OrderItem myOrderItem = new OrderItem();

                        myOrderItem.Id = myShoppingCartItem.ProductFK;

                        double myPrice = 0;

                        if (myPriceType != null)
                        {
                            myPrice = myPriceType.Price;
                            double? NewPrice = 0;

                            if ((myPriceType.DiscountDateFrom != null) && (myPriceType.DiscountDateTo != null) && (myPriceType.DiscountPercentage != null))
                            {
                                if ((DateTime.Now >= myPriceType.DiscountDateFrom) && (DateTime.Now <= myPriceType.DiscountDateTo))
                                {
                                    NewPrice = myPriceType.Price - ((myPriceType.DiscountPercentage / 100) * myPriceType.Price);
                                    myPrice = Convert.ToDouble(NewPrice);
                                }
                            }
                        }

                        myOrderItem.Price = myPrice;

                        myOrderItem.Quantity = myShoppingCartItem.Quantity;

                        myOrderItems.Add(myOrderItem);
                    }

                    //if (
                    new OrdersLogic().AddOrder(null, myLoggedUser.Id, CreditCard.Trim(), myOrderItems);
                    //{
                        //new UsersLogic().InsertCreditCardNumber(CreditCard.Trim(), myLoggedUser.Id);
                        //new ShoppingCartLogic().EmptyCart(myLoggedUser.Id);

                    //}
                 }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
コード例 #6
0
 protected async void ResetPassword(object sender, EventArgs e)
 {
     if (passwordtxt.Value != passwordvalidatetxt.Value) {
         SiteLogic.AddError("The confirm password field does no match the password field");
         return;
     }
     UsersLogic UsersLogic = new UsersLogic();
     if (await UsersLogic.ResetPassword(Request["id"], Request["code"], passwordtxt.Value))
     {
         Response.Redirect("~/account/resetpassword?success=true", false);
     }
 }
コード例 #7
0
        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {
            if (Context.User != null)
            {
                IQueryable<Role> myRoles = new UsersLogic().RetrieveUserRoles(Context.User.Identity.Name);

                List<string> myRoleList = new List<string>();

                foreach(Role myRole in myRoles)
                {
                    myRoleList.Add(myRole.Role1);
                }

                string[] myRolesArray = myRoleList.ToArray();

                GenericPrincipal myPrincipal = new GenericPrincipal(Context.User.Identity, myRolesArray);
                Context.User = myPrincipal;
            }
        }
コード例 #8
0
 public void FinishPayment()
 {
     if (VerifyPayment() == "VERIFIED")
     {
         Order.OrderLog = "VERIFIED - ZCredit order successfull";
         Order.ChargeStatus = ChargeStatusEnum.ChargedSuccessfully.ToString();
         Order.CardToken = HttpContext.Current.Request["Token"];
         Order.CardAuthNum = HttpContext.Current.Request["ApprovalNumber"];
         Order.CardHolderId = HttpContext.Current.Request["CustomerID"];
         Order.StatusId = 5;
         UsersLogic usersLogic = new UsersLogic();
         User user = usersLogic.FindByUserId(Order.UserId);
     }
     else
     {
         Order.OrderLog = "NOT VERIFIED" + " ההזמנה בZCREDIT לא עברה בהצלחה. "; // +ZCreditProviderError(HttpContext.Current.Request.Form["ApprovalNumber"]);
         Order.ChargeStatus = ChargeStatusEnum.ChargeFailed.ToString();
         Order.StatusId = 9;
     }
 }
コード例 #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.Cache.SetNoStore();

                if (!IsPostBack)
                {
                    if (Context.User.Identity.IsAuthenticated)
                    {
                        User myLoggedUser = new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name);
                        lblLoggedUser.Text = myLoggedUser.Name + " " + myLoggedUser.Surname;
                    }

                    txtSearch.Attributes.Add("DefaultText", "Search Store");
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
コード例 #10
0
        public string AppendProducts(string ParentID, string ChildID, string SearchText, string LoadAll)
        {
            try
            {
                if (Context.User.IsInRole("User"))
                {
                    int myParentID = 0;
                    int myChildID = 0;

                    if ((ParentID.Trim() != "") && (ChildID.Trim() != ""))
                    {
                        myParentID = Convert.ToInt32(ParentID.Trim());
                        myChildID = Convert.ToInt32(ChildID.Trim());
                    }

                    string HTML = "";

                    User myLoggedUser = new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name);
                    _UserType = myLoggedUser.UserType.Type;

                    Product[] myProducts = null;

                    if (SearchText == "")
                    {
                        if (myChildID == 0)
                        {
                            //parent only
                            myProducts = new ProductsLogic().RetrieveProductsForDisplayByUser(myLoggedUser.UserTypeFK, myParentID, null).ToArray();
                        }
                        else
                        {
                            //child
                            myProducts = new ProductsLogic().RetrieveProductsForDisplayByUser(myLoggedUser.UserTypeFK, null, myChildID).ToArray();
                        }
                    }
                    else
                    {
                        if (LoadAll == "false")
                        {
                            myProducts = new ProductsLogic().RetrieveProductsForDisplayBySearch(myLoggedUser.UserTypeFK, SearchText).ToArray();
                        }
                    }

                    if (LoadAll == "true")
                    {
                        myProducts = new ProductsLogic().RetrieveProductsForDisplayByUserType(myLoggedUser.UserTypeFK).ToArray();
                    }

                    if (myProducts.Length > 0)
                    {
                        for (int i = 1; i <= (myProducts.Length + 4 / 4); i++)
                        {
                            int Counter = i * 4;

                            HTML += "<tr>";

                            for (int j = (Counter - 3); j <= Counter; j++)
                            {
                                HTML += "<td>";

                                HTML += TDContents(myProducts[j - 1]);

                                HTML += "</td>";

                                if (j == myProducts.Length)
                                {
                                    goto LoopEnd;
                                }
                            }

                            HTML += "</tr>";
                        }
                    }

                LoopEnd:

                    return HTML;
                }
                else
                {
                    return "";
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
コード例 #11
0
 public string RetrieveCartTotal()
 {
     try
     {
         if (Context.User.IsInRole("User"))
         {
             User myLoggedUser = new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name);
             return "€" + new ShoppingCartLogic().RetrieveCartTotal(myLoggedUser.Id).ToString("F");
         }
         else
         {
             return "";
         }
     }
     catch (Exception Exception)
     {
         throw Exception;
     }
 }
コード例 #12
0
        //ProductsView myCurrentProduct
        /// <summary>
        /// Generates TD Contents for Product
        /// Level: External
        /// </summary>
        /// <param name="myProduct">The Product</param>
        /// <returns>HTML</returns>
        private string TDContents(Product myProduct)
        {
            try
            {
                string Name = myProduct.Name;
                string ImageURL = VirtualPathUtility.ToAbsolute(myProduct.ImageURL);
                string ProductID = myProduct.Id.ToString();
                string ProductLink = "/user/viewproduct.aspx?id=" + new Encryption().Encrypt(myProduct.Id.ToString());

                User myLoggedUser = new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name);
                UserTypeProduct myPriceType = new PriceTypesLogic().RetrievePriceTypeByID(myLoggedUser.UserTypeFK, myProduct.Id);

                string Price = "";

                if (myPriceType != null)
                {
                    Price = "€" + myPriceType.Price.ToString("F");
                    double? NewPrice = 0;

                    if ((myPriceType.DiscountDateFrom != null) && (myPriceType.DiscountDateTo != null) && (myPriceType.DiscountPercentage != null))
                    {
                        if ((DateTime.Now >= myPriceType.DiscountDateFrom) && (DateTime.Now <= myPriceType.DiscountDateTo))
                        {
                            NewPrice = myPriceType.Price - ((myPriceType.DiscountPercentage / 100) * myPriceType.Price);

                            string myDisplayedNewPrice = Convert.ToDouble(NewPrice).ToString("F");

                            Price = myPriceType.DiscountPercentage + "% Off : €" + myDisplayedNewPrice;
                        }
                    }
                }

                //string Price = new ProductsLogic().RetrieveProductPrice(_UserType, myProduct.Id).ToString("F");
                string ButtonHTML = "<input type=\"image\" class=\"ProductButton\" alt=\"\" ProductID=\"" + ProductID + "\" ClickAction=\"Add\" src=\"/images/Add.jpg\" onclick=\"return false;\" />" +
                                    "<div class=\"ProductButtonSpacer\"></div>" +
                                    "<input type=\"image\" class=\"ProductButton\" alt=\"\" ProductID=\"" + ProductID + "\" ClickAction=\"Remove\" src=\"/images/Remove.jpg\" onclick=\"return false;\"/>";
                string OutOfStock = "No Stock &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                string LowOnStock = "Low Stock &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                string TextBox = "<div class=\"MiniFontGrey\"><div style=\"padding-top: 5px; float: left;\">Quantity&nbsp;&nbsp;</div><input type=\"text\" name=\"" + ProductID + "\" class=\"CatalogTextBox\"></div>" +
                                 "<br />";

                if (myProduct.StockQuantity == 0)
                {
                    ButtonHTML = "";
                    LowOnStock = "";
                    TextBox = "<div style=\"height: 27px; width: 1px\"></div>";
                }
                else if (myProduct.StockQuantity <= myProduct.ReorderLevel)
                {
                    OutOfStock = "";
                }
                else
                {
                    LowOnStock = "";
                    OutOfStock = "";
                }

                string HTML = "<div>" +
                                  "<div class=\"ProductContent\">" +
                                      "<img class=\"ProductImage\" alt=\"\" src=\"" + ImageURL + "\" />" +
                                      "<br />" +
                                      "<a href=\"" + ProductLink + "\" target=\"_blank\" class=\"MiniFontGrey\">" + Name + "</a><br />" +
                                   "<div class=\"MiniFontBlue\">" + OutOfStock + LowOnStock + Price + "</div>" +
                                   "<br />" +
                                   TextBox +
                               "</div>" +
                               "<div class=\"ProductButtons\">" +
                                    ButtonHTML +
                               "</div>";

                return HTML;
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
コード例 #13
0
        public void RemoveFromCart(string ProductID)
        {
            try
            {
                if (Context.User.IsInRole("User"))
                {
                    Guid myProductID = Guid.Parse(ProductID.Trim());

                    User myLoggedUser = new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name);

                    new ShoppingCartLogic().RemoveFromCart(myLoggedUser.Id, myProductID);
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
コード例 #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string myProductID = null;

                try
                {
                    myProductID = new Encryption().Decrypt(Request.QueryString[0].ToString());
                }
                catch (Exception)
                {
                    Response.Redirect("~/pagenotfound.aspx");
                }

                Guid myProductGuid;

                if (Guid.TryParse(myProductID, out myProductGuid))
                {
                    Product myProduct = new ProductsLogic().RetrieveProductByID(myProductID);
                    User myLoggedUser = new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name);
                    UserTypeProduct myPriceType = new PriceTypesLogic().RetrievePriceTypeByID(myLoggedUser.UserTypeFK, myProduct.Id);

                    this.Title = "the Great Supermarket | " + myProduct.Name;
                    txtPageTitle.Text = "Viewing: " + myProduct.Name;

                    hdnProductID.Value = myProduct.Id.ToString();

                    imgProduct.ImageUrl = myProduct.ImageURL;
                    lblProductName.Text = myProduct.Name;
                    lblDescription.Text = myProduct.Description;

                    string Price = "";
                    string Stock = "";

                    if (myProduct.StockQuantity == 0)
                    {
                        Stock = "No Stock";
                        txtQuantity.Visible = false;
                        lblQuantity.Visible = false;
                        _StockAvailable = false;
                    }
                    else if (myProduct.StockQuantity <= myProduct.ReorderLevel)
                    {
                        Stock = "Low Stock";
                    }

                    if (myPriceType != null)
                    {
                        Price = "€" + myPriceType.Price.ToString("F");
                        double? NewPrice = 0;

                        if ((myPriceType.DiscountDateFrom != null) && (myPriceType.DiscountDateTo != null) && (myPriceType.DiscountPercentage != null))
                        {
                            if ((DateTime.Now >= myPriceType.DiscountDateFrom) && (DateTime.Now <= myPriceType.DiscountDateTo))
                            {
                                NewPrice = myPriceType.Price - ((myPriceType.DiscountPercentage / 100) * myPriceType.Price);

                                string myDisplayedNewPrice = Convert.ToDouble(NewPrice).ToString("F");

                                Price = myPriceType.DiscountPercentage + "% Off : €" + myDisplayedNewPrice;
                            }
                        }
                    }

                    lblPrice.Text = Stock + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" + Price;
                }
                else
                {
                    Response.Redirect("~/pagenotfound.aspx");
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
コード例 #15
0
        public string DeAllocateRole(string Email, string Role)
        {
            try
            {
                if (Context.User.IsInRole("Administrator"))
                {
                    string myEmail = Email.Trim();
                    int myRole = Convert.ToInt32(Role.Trim());

                    UserDeAllocate myResult = new UsersLogic().DeAllocateRole(myEmail, myRole);

                    if (myResult == UserDeAllocate.UserIsAdmin)
                    {
                        return "Role Cannot Be De Allocated : Same Permission";
                    }
                    else if (myResult == UserDeAllocate.OnlyUser)
                    {
                        return "User Must Either Be an Administrator, a User, or Both";
                    }
                    else
                    {
                        return "";
                    }
                }
                else
                {
                    return "";
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
コード例 #16
0
        public string[] PopulateRoles(string Email)
        {
            try
            {
                if (Context.User.IsInRole("Administrator"))
                {
                    string myEmail = Email.Trim();

                    List<Role> myCurrentRoles = new UsersLogic().RetrieveUserRolesByEmail(myEmail).ToList();
                    List<Role> AllRoles = new RolesLogic().RetrieveAllRoles().ToList();

                    string CurrentRoleHTML = "";
                    string AvailableRoleHTML = "";

                    foreach (Role myRole in myCurrentRoles)
                    {
                        CurrentRoleHTML += "<option value=\"" + myRole.Id + "\">" + myRole.Role1 + "</option>";
                    }

                    foreach (Role myRole in myCurrentRoles)
                    {
                        Role ToRemove = AllRoles.SingleOrDefault(r => r.Role1 == myRole.Role1);
                        AllRoles.Remove(ToRemove);
                    }

                    foreach (Role myRole in AllRoles)
                    {
                        AvailableRoleHTML += "<option value=\"" + myRole.Id + "\">" + myRole.Role1 + "</option>";
                    }

                    return new string[2] { CurrentRoleHTML, AvailableRoleHTML };
                }
                else
                {
                    return new string[] { "" };
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
コード例 #17
0
        public string LoadShoppingCartItems()
        {
            try
            {
                if (Context.User.IsInRole("User"))
                {
                    string HTML = "";

                    User myLoggedUser = new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name);
                    List<ShoppingCart> myShoppingCartItems = new ShoppingCartLogic().RetrieveAllShoppingCartItems(myLoggedUser.Id).ToList();

                    HTML += "<table>";

                    int Counter = 0;

                    foreach (ShoppingCart myShoppingCartItem in myShoppingCartItems)
                    {
                        UserTypeProduct myPriceType = new PriceTypesLogic().RetrievePriceTypeByID(myLoggedUser.UserTypeFK, myShoppingCartItem.ProductFK);

                        string PriceOutput = "";

                        if (myPriceType != null)
                        {
                            PriceOutput = myPriceType.Price.ToString("F");
                            double? NewPrice = 0;

                            if ((myPriceType.DiscountDateFrom != null) && (myPriceType.DiscountDateTo != null) && (myPriceType.DiscountPercentage != null))
                            {
                                if ((DateTime.Now >= myPriceType.DiscountDateFrom) && (DateTime.Now <= myPriceType.DiscountDateTo))
                                {
                                    NewPrice = myPriceType.Price - ((myPriceType.DiscountPercentage / 100) * myPriceType.Price);

                                    string myDisplayedNewPrice = Convert.ToDouble(NewPrice).ToString("F");

                                    PriceOutput = myDisplayedNewPrice + " : " + myPriceType.DiscountPercentage + " % Off";
                                }
                            }
                        }

                        HTML += "<tr class=\"GridViewTuple\">";

                        HTML += "<td>";
                        HTML += new ProductsLogic().RetrieveProductByID(myShoppingCartItem.ProductFK.ToString()).Name;
                        HTML += "</td>";

                        HTML += "<td>";
                        HTML += "<div style=\"padding-top: 4px; float: left;\">x&nbsp;&nbsp;</div><input class=\"CatalogTextBox\" id=\"" + myShoppingCartItem.ProductFK + "\" Use=\"Quantity\" type=\"text\" value=\"" + myShoppingCartItem.Quantity.ToString() + "\">";
                        HTML += "</td>";

                        HTML += "<td> at </td>";

                        HTML += "<td>";
                        HTML += "€ " + PriceOutput;
                        HTML += "</td>";

                        HTML += "<td>";
                        HTML += "<div Use=\"ErrorDiv\" ProductID=\"" + myShoppingCartItem.ProductFK + "\" class=\"MiniFontBlue\">Not Enough Stock</div>";
                        HTML += "</td>";

                        HTML += "</tr>";

                        Counter++;
                    }

                    HTML += "</table>";

                    return HTML;
                }
                else
                {
                    return "";
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
コード例 #18
0
        public string PayDeal()
        {
            string ret = "", ret1 = "", ret2 = "", ret3 = "", ret4 = "", ret5 = "", ret6 = "";

            string siteurl = SiteLogic.Config()["siteurl"];
            string retMsg = "";

            string authNUm = Order.CardAuthNum;
            string cardNumber = Order.CardToken, expMonth = "";
            int ReferenceNumber = 0, Validation_Result_Code = 0;
            clsZCreditWSSoapClient sc = new clsZCreditWSSoapClient();
            sc.CommitSimpleTransaction("2648414013", //TerminalNumber,  0963222014
                 "7351585986",    //Password, 0963222014
                 "",      //Track2,,
                 ref cardNumber,      //CardNumber,,
                 ref expMonth,    //ExpDate_MMYY,
                 (float)Order.GetGrandTotal(),     //TransactionSum,,
                 Order.CardHolderId,   //HolderID,,
                 "",     //CVV,,
                 false,    //IsCustomerPresent,,
                 ref authNUm,    //AuthNum,,
                 out Validation_Result_Code,    //Validation_Result_Code,
                 out ret,    //Validation_Result_Message,
                 out ret1,    //CardName,,
                 out ret2,    //CardIssuerCode,,
                 out ret3,    //CardFinancerCode,,
                 out ret4,    //CardBrandCode,,
                 out ReferenceNumber,    //ReferenceNumber,,
                 out ret5,    //VoucherNumber,,
                 out ret6);    //ApprovalType,

            if (Validation_Result_Code == 0)
            {
                Order.AdminComments = "AuthNum: " + authNUm + ", Validation_Result_Code: " + Validation_Result_Code + ", ReferenceNumber: " + ReferenceNumber;
                Order.StatusId = 6;
                MailLogic ml = new MailLogic();
                UsersLogic UsersLogic = new UsersLogic();
                User user = UsersLogic.FindByUserId(Order.UserId);
                Dictionary<string, string> Placeholders = new Dictionary<string, string>
                {
                    { "firstname", user.FirstName },
                    { "orderid", Order.OrdersId.ToString() }
                };
                ml.sendMailTemplate("SiteNotification", user.Email, Placeholders);
            }
            else
            {
                Order.AdminComments += " Validation_Result_Message: " + ret + ", AuthNum: " + ", Validation_Result_Code: " + Validation_Result_Code + ", ReferenceNumber: " + ReferenceNumber;
            }

            return ret;
        }
コード例 #19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Context.User.Identity.IsAuthenticated)
                {
                    string myOrderID = Request.QueryString[0].ToString();
                    Guid myOrderGuid;

                    if (Guid.TryParse(myOrderID, out myOrderGuid))
                    {
                        Order myOrder = new OrdersLogic().RetrieveOrderByID(myOrderGuid);
                        IQueryable<OrderProduct> myOrderItems = new OrdersLogic().RetrieveItemsByOrderID(myOrderGuid);

                        bool HasAccess = false;

                        if(Context.User.IsInRole("Administrator"))
                        {
                            HasAccess = true;
                        }
                        else
                        {
                            if (myOrder.UserFK == new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name).Id)
                            {
                                HasAccess = true;
                            }
                        }

                        //User has access to the order
                        if (HasAccess)
                        {
                            string HTML = "<table style=\"font-family: Arial;\"  cellpadding=\"6\">";

                            HTML += "<tr>";
                                HTML += "<td>";
                                HTML += "Order ID: ";
                                HTML += "</td>";
                                HTML += "<td>";
                                HTML += myOrder.Id;
                                HTML += "</td>";
                            HTML += "</tr>";

                            if(myOrder.SupplierFK == null)
                            {
                                HTML += "<tr>";
                                HTML += "<td>";
                                HTML += "Name: ";
                                HTML += "</td>";
                                HTML += "<td>";
                                HTML += myOrder.User.Name + " " + myOrder.User.Surname;
                                HTML += "</td>";
                                HTML += "</tr>";

                                string[] Address = myOrder.User.StreetAddress.Split('|');

                                HTML += "<tr>";
                                HTML += "<td>";
                                HTML += "Address: ";
                                HTML += "</td>";
                                HTML += "<td>";
                                HTML += Address[0];
                                HTML += "</td>";
                                HTML += "</tr>";

                                HTML += "<tr>";
                                HTML += "<td>";
                                HTML += "</td>";
                                HTML += "<td>";
                                HTML += Address[1];
                                HTML += "</td>";
                                HTML += "</tr>";

                                HTML += "<tr>";
                                HTML += "<td>";
                                HTML += "Town: ";
                                HTML += "</td>";
                                HTML += "<td>";
                                HTML += myOrder.User.Town.Town1;
                                HTML += "</td>";
                                HTML += "</tr>";

                                HTML += "<tr>";
                                HTML += "<td>";
                                HTML += "Country: ";
                                HTML += "</td>";
                                HTML += "<td>";
                                HTML += myOrder.User.Town.Country.Country1;
                                HTML += "</td>";
                                HTML += "</tr>";
                            }
                            else
                            {
                                HTML += "<tr>";
                                HTML += "<td>";
                                HTML += "Supplier: ";
                                HTML += "</td>";
                                HTML += "<td>";
                                HTML += myOrder.Supplier.Supplier1;
                                HTML += "</td>";
                                HTML += "</tr>";
                            }

                            HTML += "<tr>";
                            HTML += "<td>";
                            HTML += "Status: ";
                            HTML += "</td>";
                            HTML += "<td>";
                            HTML += myOrder.OrderStatus.Status;
                            HTML += "</td>";

                            HTML += "</tr>";
                            HTML += "<tr>";
                            HTML += "<td>";
                            HTML += "Date Placed: ";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += myOrder.OrderDate;
                            HTML += "</td>";

                            HTML += "</tr>";

                            HTML += "</table>";

                            HTML += "<br/>";

                            HTML += "<table style=\"font-family: Arial;\"  cellpadding=\"6\">";

                            HTML += "<tr>";

                            HTML += "<td>";
                            HTML += "Product";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "Quantity";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "Price";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "VAT Rate";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "Discount (Incl.)";
                            HTML += "</td>";

                            HTML += "</tr>";

                            double TotalPrice = 0;
                            double TotalVat = 0;

                            foreach (OrderProduct myOrderItem in myOrderItems)
                            {
                                Product myProduct = new ProductsLogic().RetrieveProductByID(myOrderItem.ProductFK.ToString());

                                User myUser = null;
                                UserTypeProduct myPriceType = null;

                                if (myOrder.UserFK != null)
                                {
                                    myUser = new UsersLogic().RetrieveUserByID(Guid.Parse(myOrder.UserFK.ToString()));
                                    myPriceType = new PriceTypesLogic().RetrievePriceTypeByID(myUser.UserTypeFK, myProduct.Id);
                                }
                                else
                                {
                                    UserType myUserType = new UserTypesLogic().RetrieveUserTypeByName("Wholesaler");
                                    myPriceType = new PriceTypesLogic().RetrievePriceTypeByID(myUserType.Id, myProduct.Id);
                                }

                                HTML += "<tr>";

                                HTML += "<td>";
                                HTML += myProduct.Name;
                                HTML += "</td>";

                                HTML += "<td>";
                                HTML += " x " + myOrderItem.Quantity;
                                HTML += "</td>";

                                HTML += "<td>";
                                HTML += " at € " + myOrderItem.Price.ToString("F");
                                HTML += "</td>";

                                HTML += "<td>";
                                HTML += myProduct.Vatrate.Vatrate1 + "% VAT";
                                HTML += "</td>";

                                TotalPrice += myOrderItem.Price * myOrderItem.Quantity;
                                TotalVat += ((myProduct.Vatrate.Vatrate1 / 100) * (myOrderItem.Price * myOrderItem.Quantity));

                                HTML += "<td>";

                                if((myOrder.OrderDate >= myPriceType.DiscountDateFrom) && (myOrder.OrderDate <= myPriceType.DiscountDateTo))
                                {
                                    HTML += myPriceType.DiscountPercentage + "% Discount";
                                }

                                HTML += "</td>";

                                HTML += "</tr>";
                            }

                            HTML += "<tr>";

                            HTML += "<td>";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "Subtotal : ";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "€ " + (TotalPrice - TotalVat).ToString("F");
                            HTML += "</td>";

                            HTML += "<tr>";

                            HTML += "<td>";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "VAT : ";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "€ " + TotalVat.ToString("F");
                            HTML += "</td>";

                            HTML += "</tr>";

                            HTML += "<tr>";

                            HTML += "<td>";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "Total : ";
                            HTML += "</td>";

                            HTML += "<td>";
                            HTML += "€ " + TotalPrice.ToString("F");
                            HTML += "</td>";

                            HTML += "</tr>";
                            HTML += "</table>";

                            lblOutput.Text = HTML;
                        }
                        else
                        {
                            Response.Redirect("~/default.aspx");
                        }
                    }
                }
                else
                {
                    Response.Redirect("~/default.aspx");
                }

            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }