Exemple #1
0
        protected void Advertize_Click(object sender, EventArgs e)
        {
            string LoggedInUser = HttpContext.Current.User.Identity.Name;
            DateTime StartDate = Calendar1.SelectedDate;

            string StartTimeTxt = txtStartTime.Text;
            DateTime StartTime = DateTime.ParseExact(StartTimeTxt, "hh:mm tt", System.Globalization.CultureInfo.CurrentCulture);
            StartDate = StartDate.AddHours(StartTime.Hour);
            StartDate = StartDate.AddMinutes(StartTime.Minute);

            string EndTimeTxt = txtEndTime.Text;
            DateTime EndTime = DateTime.ParseExact(EndTimeTxt, "hh:mm tt", System.Globalization.CultureInfo.CurrentCulture);
            DateTime EndDate = Calendar2.SelectedDate;
            EndDate = EndDate.AddHours(EndTime.Hour);
            EndDate = EndDate.AddMinutes(EndTime.Minute);

            string CategoryName = CategoriesDropDown.SelectedItem.Text;
            int CategoryId = CategoriesDropDown.SelectedIndex;
            DataContext _db = new DataContext();
            LiveBid BidToPlace = new LiveBid {
                ProvidingUserName = LoggedInUser,
                AvailableStartTime = StartDate,
                AvailableEndTime = EndDate,
                DesiredBidPrice = Convert.ToDouble(TextBox1.Text),
                Status = true,
                CategoryID = _db.Categories.SingleOrDefault(c => c.CategoryName == CategoryName).CategoryID,
                Category = _db.Categories.SingleOrDefault(c => c.CategoryName == CategoryName),//fix - What if calendar entries are empty
                AppUser = _db.Users.Single(u => u.Id == LoggedInUser)
            };
            _db.LiveBids.Add(BidToPlace);
            _db.SaveChanges();
            Response.Redirect("LiveBids.aspx");
        }
 public void Dispose()
 {
     if (_db != null)
     {
         _db.Dispose();
         _db = null;
     }
 }
Exemple #3
0
 public IQueryable<LiveBid> GetCategoryBids([QueryString("catid")] int? categoryId)
 {
     var _db = new talker.Models.DataContext();
     IQueryable<LiveBid> query = _db.LiveBids;
     if (categoryId.HasValue && categoryId > 0)
     {
         query = query.Where(p => p.CategoryID == categoryId);
     }
     return query;
 }
Exemple #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     List<ListItem> categories = new List<ListItem>();
     var _db = new talker.Models.DataContext();
     IQueryable<Category> query = _db.Categories;
     List<Category> dd_categories = (from records in _db.Categories
                                  select records).ToList();
     foreach (Category cat in dd_categories){
         categories.Add(new ListItem(cat.CategoryName));
     }
     CategoriesDropDown.DataSource = categories;
     CategoriesDropDown.DataBind();
 }
Exemple #5
0
 public IQueryable<LiveBid> GetLiveBid(
                 [QueryString("LiveBidId")] int? LiveBidId)
 {
     var _db = new talker.Models.DataContext();
     IQueryable<LiveBid> query = _db.LiveBids;
     if (LiveBidId.HasValue && LiveBidId > 0)
     {
         query = query.Where(p => p.BidID == LiveBidId);
     }
     else
     {
         query = null;
     }
     return query;
 }
Exemple #6
0
 protected void PlaceBid_Click(object sender, EventArgs e)
 {
     DataContext _db = new DataContext();
     string RawId = Request.QueryString["LiveBidId"];
     int OriginatingBidId = Convert.ToInt32(RawId);
     PlacedBid placedBid = new PlacedBid
     {
         ReceivingMemberId = HttpContext.Current.User.Identity.Name,
         ProvidingMemberId = _db.LiveBids.SingleOrDefault(p => p.BidID == OriginatingBidId).ProvidingUserName,
         BidId = OriginatingBidId,
         BidTime = DateTime.Now
     };
     _db.PlacedBids.Add(placedBid);
     _db.SaveChanges();
     Response.Redirect("LiveBids.aspx");
 }
 public IQueryable<Discussion> GetUpcomingDiscussions(
                 [QueryString("UserId")] int? UserId)
 {
     var _db = new talker.Models.DataContext();
     IQueryable<Discussion> query = _db.Discussions;
     string loggedInUser = HttpContext.Current.User.Identity.Name;
     if (!string.IsNullOrWhiteSpace(loggedInUser))
     {
         query = query.Where(p => p.ProvidingUserName == loggedInUser);
         query = query.Where(p => p.DiscussionStartTime > DateTime.Now);
     }
     else
     {
         query = null;
     }
     return query;
 }
Exemple #8
0
 protected void Advertize_Click(object sender, EventArgs e)
 {
     string LoggedInUser = HttpContext.Current.User.Identity.Name;
     DateTime StartTime = Calendar1.SelectedDate;
     DateTime EndTime = Calendar2.SelectedDate;
     string CategoryName = CategoriesDropDown.SelectedValue;
     DataContext _db = new DataContext();
     LiveBid BidToPlace = new LiveBid {
         ProvidingUserName = LoggedInUser,
         AvailableStartTime = StartTime,
         AvailableEndTime = EndTime,
         DesiredBidPrice = Convert.ToDouble(TextBox1.Text),
         Status = true,
         Category = _db.Categories.SingleOrDefault(c => c.CategoryName == CategoryName)//fix - What if calendar entries are empty
     };
     _db.LiveBids.Add(BidToPlace);
     _db.SaveChanges();
     Response.Redirect("LiveBids.aspx");
 }
Exemple #9
0
        //R-code
        public void AddToUser(string id)
        {
            // Retrieve the product from the database.
            DataContext _db = new DataContext();

            var user = _db.Users.SingleOrDefault(c => c.Id == id);
            if (user == null)
            { // Create a new user if no user exists.
                user = new User {
                    Id = id,
                    FName = Name.Text,
                    LName = "null",
                    DateCreated = DateTime.Now
                };

                _db.Users.Add(user);
            }
            else
            { // If the item does exist in the cart, // then add one to the quantity.
                //user.Quantity++;
            } _db.SaveChanges();
        }
Exemple #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string RawId = Request.QueryString["bidId"];
            DataContext _db = new DataContext();
            int OriginatingBidId = Convert.ToInt32(RawId);

            Discussion newDiscussion = new Discussion
            {
                ProvidingUserName = _db.LiveBids.SingleOrDefault(p => p.BidID == OriginatingBidId).ProvidingUserName,
                ReceivingUserName = HttpContext.Current.User.Identity.Name,
                DiscussionStartTime = _db.LiveBids.SingleOrDefault(p => p.BidID == OriginatingBidId).AvailableStartTime,
                DiscussionEndTime = _db.LiveBids.SingleOrDefault(p => p.BidID == OriginatingBidId).AvailableEndTime,
                TransactionAmount = _db.LiveBids.SingleOrDefault(p => p.BidID == OriginatingBidId).DesiredBidPrice,
                Status = true,
                DateCreated = DateTime.Now
            };
            LiveBid soldBid = _db.LiveBids.SingleOrDefault(p => p.BidID == OriginatingBidId);
            _db.LiveBids.Remove(soldBid);
            _db.Discussions.Add(newDiscussion);
            _db.SaveChanges();
            Response.Redirect("AddToCart.aspx?discussionId=" + newDiscussion.DiscussionID);
        }
Exemple #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                NVPAPICaller payPalCaller = new NVPAPICaller();

                string retMsg = "";
                string token = "";
                string PayerID = "";
                NVPCodec decoder = new NVPCodec();
                token = Session["token"].ToString();

                bool ret = payPalCaller.GetCheckoutDetails(token, ref PayerID, ref decoder, ref retMsg);
                if (ret)
                {
                    Session["payerId"] = PayerID;

                    var myOrder = new Order();
                    myOrder.OrderDate = Convert.ToDateTime(decoder["TIMESTAMP"].ToString());
                    myOrder.Username = User.Identity.Name;
                    myOrder.FirstName = decoder["FIRSTNAME"].ToString();
                    myOrder.LastName = decoder["LASTNAME"].ToString();
                    myOrder.Address = decoder["SHIPTOSTREET"].ToString();
                    myOrder.City = decoder["SHIPTOCITY"].ToString();
                    myOrder.State = decoder["SHIPTOSTATE"].ToString();
                    myOrder.PostalCode = decoder["SHIPTOZIP"].ToString();
                    myOrder.Country = decoder["SHIPTOCOUNTRYCODE"].ToString();
                    myOrder.Email = decoder["EMAIL"].ToString();
                    myOrder.Total = Convert.ToDecimal(decoder["AMT"].ToString());

                    // Verify total payment amount as set on CheckoutStart.aspx.
                    try
                    {
                        decimal paymentAmountOnCheckout = Convert.ToDecimal(Session["payment_amt"].ToString());
                        decimal paymentAmoutFromPayPal = Convert.ToDecimal(decoder["AMT"].ToString());
                        if (paymentAmountOnCheckout != paymentAmoutFromPayPal)
                        {
                            Response.Redirect("CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch.");
                        }
                    }
                    catch (Exception)
                    {
                        Response.Redirect("CheckoutError.aspx?" + "Desc=Amount%20total%20mismatch.");
                    }

                    // Get DB context.
                    DataContext _db = new DataContext();

                    // Add order to DB.
                    _db.Orders.Add(myOrder);
                    _db.SaveChanges();

                    // Get the shopping cart items and process them.
                    using (talker.logic.ShoppingCartActions usersShoppingCart = new talker.logic.ShoppingCartActions())
                    {
                        List<CartItem> myOrderList = usersShoppingCart.GetCartItems();

                        // Add OrderDetail information to the DB for each product purchased.
                        for (int i = 0; i < myOrderList.Count; i++)
                        {
                            // Create a new OrderDetail object.
                            var myOrderDetail = new OrderDetail();
                            myOrderDetail.OrderId = myOrder.OrderId;
                            myOrderDetail.Username = User.Identity.Name;
                            myOrderDetail.ProductId = myOrderList[i].DiscussionId;
                            myOrderDetail.Quantity = 1;
                            myOrderDetail.UnitPrice = myOrderList[i].Discussion.TransactionAmount;

                            // Add OrderDetail to DB.
                            _db.OrderDetails.Add(myOrderDetail);
                            _db.SaveChanges();
                        }

                        // Set OrderId.
                        Session["currentOrderId"] = myOrder.OrderId;

                        // Display Order information.
                        List<Order> orderList = new List<Order>();
                        orderList.Add(myOrder);
                        ShipInfo.DataSource = orderList;
                        ShipInfo.DataBind();

                        // Display OrderDetails.
                        OrderItemList.DataSource = myOrderList;
                        OrderItemList.DataBind();
                    }
                }
                else
                {
                    Response.Redirect("CheckoutError.aspx?" + retMsg);
                }
            }
        }
Exemple #12
0
 public IQueryable<Category> GetCategories()
 {
     var _db = new talker.Models.DataContext();
     IQueryable<Category> query = _db.Categories;
     return query;
 }
 //I will never need this method since a bid once purchased is consumed.
 public void UpdateItem(string updateCartID, int updateDiscussionID, int quantity)
 {
     using (var _db = new talker.Models.DataContext())
     {
         try
         {
             var myItem = (from c in _db.ShoppingCartItems where c.CartId == updateCartID && c.Discussion.DiscussionID == updateDiscussionID select c).FirstOrDefault();
             if (myItem != null)
             {
                 //myItem.Quantity = quantity;
                 _db.SaveChanges();
             }
         }
         catch (Exception exp)
         {
             throw new Exception("ERROR: Unable to Update Cart Item - " + exp.Message.ToString(), exp);
         }
     }
 }
Exemple #14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     string uname = HttpContext.Current.User.Identity.Name;
     DataContext _db = new DataContext();
 }
 public void UpdateShoppingCartDatabase(String cartId, ShoppingCartUpdates[] CartItemUpdates)
 {
     using (var db = new talker.Models.DataContext())
     {
         try
         {
             int CartItemCount = CartItemUpdates.Count();
             List<CartItem> myCart = GetCartItems();
             foreach (var cartItem in myCart)
             {
                 // Iterate through all rows within shopping cart list
                 for (int i = 0; i < CartItemCount; i++)
                 {
                     if (cartItem.Discussion.DiscussionID == CartItemUpdates[i].DiscussionId)
                     {
                         if (CartItemUpdates[i].PurchaseQuantity < 1 || CartItemUpdates[i].RemoveItem == true)
                         {
                             RemoveItem(cartId, cartItem.DiscussionId);
                         }
                         else
                         {
                             UpdateItem(cartId, cartItem.DiscussionId, CartItemUpdates[i].PurchaseQuantity);
                         }
                     }
                 }
             }
         }
         catch (Exception exp)
         {
             throw new Exception("ERROR: Unable to Update Cart Database - " + exp.Message.ToString(), exp);
         }
     }
 }
 public void RemoveItem(string removeCartID, int removeDiscussionID)
 {
     using (var _db = new talker.Models.DataContext())
     {
         try
         {
             var myItem = (from c in _db.ShoppingCartItems where c.CartId == removeCartID && c.Discussion.DiscussionID == removeDiscussionID select c).FirstOrDefault();
             if (myItem != null)
             {
                 // Remove Item.
                 _db.ShoppingCartItems.Remove(myItem);
                 _db.SaveChanges();
             }
         }
         catch (Exception exp)
         {
             throw new Exception("ERROR: Unable to Remove Cart Item - " + exp.Message.ToString(), exp);
         }
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // Verify user has completed the checkout process.
                if ((string)Session["userCheckoutCompleted"] != "true")
                {
                    Session["userCheckoutCompleted"] = string.Empty;
                    Response.Redirect("CheckoutError.aspx?" + "Desc=Unvalidated%20Checkout.");
                }

                NVPAPICaller payPalCaller = new NVPAPICaller();

                string retMsg = "";
                string token = "";
                string finalPaymentAmount = "";
                string PayerID = "";
                NVPCodec decoder = new NVPCodec();

                token = Session["token"].ToString();
                PayerID = Session["payerId"].ToString();
                finalPaymentAmount = Session["payment_amt"].ToString();

                bool ret = payPalCaller.DoCheckoutPayment(finalPaymentAmount, token, PayerID, ref decoder, ref retMsg);
                if (ret)
                {
                    // Retrieve PayPal confirmation value.
                    string PaymentConfirmation = decoder["PAYMENTINFO_0_TRANSACTIONID"].ToString();
                    TransactionId.Text = PaymentConfirmation;

                    DataContext _db = new DataContext();
                    // Get the current order id.
                    int currentOrderId = -1;
                    if (Session["currentOrderId"] != string.Empty)
                    {
                        currentOrderId = Convert.ToInt32(Session["currentOrderID"]);
                    }
                    Order myCurrentOrder;
                    if (currentOrderId >= 0)
                    {
                        // Get the order based on order id.
                        myCurrentOrder = _db.Orders.Single(o => o.OrderId == currentOrderId);
                        // Update the order to reflect payment has been completed.
                        myCurrentOrder.PaymentTransactionId = PaymentConfirmation;
                        // Save to DB.
                        _db.SaveChanges();
                    }

                    // Clear shopping cart.
                    using (talker.logic.ShoppingCartActions usersShoppingCart =
                        new talker.logic.ShoppingCartActions())
                    {
                        usersShoppingCart.EmptyCart();
                    }

                    // Clear order id.
                    Session["currentOrderId"] = string.Empty;
                }
                else
                {
                    Response.Redirect("CheckoutError.aspx?" + retMsg);
                }
            }
        }