public ActionResult Create(userTable u)
        {
            using (ac)
            {
                ac.userTables.Add(u);
                ac.SaveChanges();

                return(RedirectToAction("Login"));
            }
        }
Beispiel #2
0
 public static void AddUser(User user)
 {
     using (AuctionEntities au = new AuctionEntities())
     {
         if (user.Id == 0)
         {
             au.Users.Add(user);
         }
         else
         {
             User dbUser = au.Users.Find(user.Id);
             if (dbUser != null)
             {
                 dbUser.IdRole = user.IdRole;
                 dbUser.Login = user.Login;
                 dbUser.Password = user.Password;
                 dbUser.Email = user.Email;
                 dbUser.Phone = user.Phone;
                 dbUser.Name = user.Name;
                 dbUser.Address = user.Address;
             }
         }
         au.SaveChanges();
     }
 }
Beispiel #3
0
        private void NotifyAuctionEnd(Guid itemId)
        {
            var context = new AuctionEntities();

            var item = context.Items.Find(itemId);

            item.IsAvailable = false;

            if (item.BuyerId != null)
            {
                var sellerEmail = context.Accounts.Find(item.SellerId).Email;
                context.Notifications.Add(new Notification
                {
                    Id         = Guid.NewGuid(),
                    Message    = "Auction has been finished, you've purchased the product!\nPlease contact seller via email: " + sellerEmail,
                    ReceiverId = item.BuyerId.Value
                });
            }

            context.Notifications.Add(new Notification
            {
                Id         = Guid.NewGuid(),
                Message    = "Auction has been finished!\nPlease contact buyer via email: " + item.BuyerAccount.Email,
                ReceiverId = item.SellerId
            });

            context.SaveChanges();
        }
        public ActionResult BidFromSearch(productTable upd)
        {
            //upd.biddedPrice = 69;
            //ViewBag.shohan = new SelectList(acForBid.productTables, "productID", "basePrice");

            searchProduct.Entry(upd).State = EntityState.Modified;
            searchProduct.SaveChanges();
            return(RedirectToAction("ShowBidListForUser", "Product"));
        }
 public ActionResult uploadProduct(productTable pt)
 {
     using (acForproduct)
     {
         acForproduct.productTables.Add(pt);
         acForproduct.SaveChanges();
         return(RedirectToAction("ShowListForUser"));
         //return RedirectToAction("PORE KORBO");
     }
 }
Beispiel #6
0
        public ActionResult updateBid(productTable upd)
        {
            //upd.biddedPrice = 69;
            //ViewBag.shohan = new SelectList(acForBid.productTables, "productID", "basePrice");

            acForBid.Entry(upd).State = EntityState.Modified;
            acForBid.SaveChanges();

            //return returnre("availableProducts");
            //return RedirectToAction("~/Bid/availableProducts");
            //return View("availableProducts");
            return(RedirectToAction("ShowBidListForUser", "Product"));
        }
Beispiel #7
0
        public static void AddSection(Section section)
        {
            using (AuctionEntities au = new AuctionEntities())
            {
                if (section.Id == 0)
                {
                    au.Sections.Add(section);
                }
                else
                {
                    Section dbSection = au.Sections.Find(section.Id);
                    if (dbSection != null)
                    {
                        dbSection.NameSection = section.NameSection;

                    }
                }
                au.SaveChanges();
            }
        }
Beispiel #8
0
        public static void UpdateLotsStatus()
        {
            using (AuctionEntities au = new AuctionEntities())
            {
                IEnumerable<Lot> lots = au.Lots
                .Where(l => l.EndDate <= DateTime.Now && l.Status != false).ToList();

                if (lots.Any())
                {
                    foreach (Lot lot in lots)
                    {
                        lot.Status = false;
                        AddLot(lot, au);
                    }
                }

                IEnumerable<UserLot> userLots = au.UserLots
                .Where(ul => ul.Lot.Status == false).ToList();

                if (userLots.Any())
                {
                    foreach (UserLot userLot in userLots)
                    {
                        if (userLot.idStatus == 1)
                        {
                            userLot.idStatus = 4;
                            AddUserLot(userLot, au);
                        }
                        if (userLot.idStatus == 2)
                        {
                            userLot.idStatus = 5;
                            AddUserLot(userLot, au);
                        }
                    }
                }
                au.SaveChanges();
            }
        }
Beispiel #9
0
 public void CreateAuction(Data.Auction auction)
 {
     _auctionEntities.Auctions.Add(auction);
     _auctionEntities.SaveChanges();
 }