public IActionResult DeleteExpiredItem(Guid productId) { var product = dbContext.ExpiredItems.Find(productId); dbContext.ExpiredItems.Remove(product); dbContext.SaveChanges(); hubContext.Clients.All.SendAsync("refreshNotifications"); return(RedirectToAction("index")); }
public ActionResult Create([Bind(Include = "BuyerID,BuyerFullName,BuyerPhoneNumber,BuyerEmailAddress")] Buyer buyer) { if (ModelState.IsValid) { db.Buyers.Add(buyer); db.SaveChanges(); return(Redirect("/Bids/Create")); } return(View(buyer)); }
public ActionResult Create([Bind(Include = "Id,Title,Description,OpeningTime,ClosingTime")] Auction auction) { if (ModelState.IsValid) { db.Auctions.Add(auction); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(auction)); }
public ActionResult Create([Bind(Include = "SellerID,SellerFullName,SellerPhoneNumber,SellerEmailAddress")] Seller seller) { if (ModelState.IsValid) { db.Sellers.Add(seller); db.SaveChanges(); return(Redirect("/Items/Create")); } return(View(seller)); }
public ActionResult Create([Bind(Include = "ItemID,ItemName,ItemDescription,SellerID")] Item item) { if (ModelState.IsValid) { db.Items.Add(item); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.SellerID = new SelectList(db.Sellers, "SellerID", "SellerFullName", item.SellerID); return(View(item)); }
public ActionResult Create([Bind(Include = "Id,Name,Description,StartingAmount,Donor,AuctionId")] AuctionItem auctionItem) { if (ModelState.IsValid) { db.AuctionItems.Add(auctionItem); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.AuctionId = new SelectList(db.Auctions, "Id", "Title", auctionItem.AuctionId); return(View(auctionItem)); }
public ActionResult Create([Bind(Include = "BidID,BidAmount,TimeStamp,ItemID,BuyerID")] Bid bid) { if (ModelState.IsValid) { db.Bids.Add(bid); db.SaveChanges(); return(Redirect("Index")); } ViewBag.BuyerID = new SelectList(db.Buyers, "BuyerID", "BuyerFullName", bid.BuyerID); ViewBag.ItemID = new SelectList(db.Items, "ItemID", "ItemName", bid.ItemID); return(View(bid)); }
public void SeedUsers(AuctionDbContext context) { var store = new UserStore<User>(context); var manager = new UserManager<User>(store); User admin = new User { UserName = "******", Email = "*****@*****.**", FirstName = "Tosho", LastName = "Ivanov", PhoneNumber = "+3591234569", SecurityStamp = Guid.NewGuid().ToString(), PasswordHash = this.hasher.HashPassword("1"), }; User pesho = new User { UserName = "******", Email = "*****@*****.**", FirstName = "Pesho", LastName = "Goshov", PhoneNumber = "+3591234567", SecurityStamp = Guid.NewGuid().ToString(), PasswordHash = this.hasher.HashPassword("1"), }; User gosho = new User { UserName = "******", Email = "*****@*****.**", FirstName = "Gosho", LastName = "Toshov", PhoneNumber = "+3591234568", SecurityStamp = Guid.NewGuid().ToString(), PasswordHash = this.hasher.HashPassword("1"), }; this.Users.Add(pesho); this.Users.Add(gosho); this.Users.Add(admin); context.Users.AddOrUpdate(this.Users.ToArray()); context.SaveChanges(); var adminId = context.Users.FirstOrDefault(u => u.UserName == "*****@*****.**").Id; manager.AddToRole(adminId, "Admin"); context.SaveChanges(); }
/// <summary> /// Execute job /// </summary> /// <param name="con"></param> public void Execute(IJobExecutionContext con) { var lots = context.Lots.Where(x => x.EndTime <= DateTime.Now && x.IsCompleted == false); foreach (var lot in lots.ToList()) { lot.IsCompleted = true; context.SaveChanges(); if (lot.Bids.Any()) { var winerId = lot.Bids.Last().UserId; var winer = userManager.FindById(winerId); if (winer != null) { using (var message = new MailMessage()) { message.To.Add(winer.Email); message.Subject = "Test"; message.Body = String.Format( "Dear {0},\n\n thank you for purchase of {1} at the auction price {2}\n\nAuction support", winer.FirstName, lot.Name, lot.CurrentPrice); SmtpClient smtp = new SmtpClient(); smtp.Send(message); } } } } }
public IActionResult Approveitem(ItemVM itemVM, Item item) { var checkid = db.Items.Find(itemVM.Id); if (checkid != null) { var i = db.Items.Where(i => i.Status == false); if (i != null) { item = db.Items.Find(itemVM.Id); item.Status = true; db.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("AdminListItem")); } } return(View("AdminListItem")); }
public IActionResult Resetpassword(string password, string confirmpassword, Account account) { if (HttpContext.Session.GetString("email") != null) { if (password == confirmpassword) { if (HttpContext.Session.GetInt32("checkid") != null) { var hashpassword = BCrypt.Net.BCrypt.HashPassword(password); account = db.Accounts.Find((HttpContext.Session.GetInt32("checkid"))); account.Password = hashpassword; db.Entry(account).State = Microsoft.EntityFrameworkCore.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Login")); } } else { ViewBag.Failed = "The password and confirm password do not match"; return(View()); } } return(View()); }
public ActionResult Create([Bind(Include = "Id,Amount,AuctionItemId,Bidder")] Bid bid) { if (ModelState.IsValid) { db.Bids.Add(bid); db.SaveChanges(); var context = GlobalHost.ConnectionManager.GetHubContext <Hubs.AuctionHub>(); context.Clients.All.newBid(bid.AuctionItemId, bid.Amount); return(RedirectToAction("Index", new { id = bid.AuctionItemId })); } return(View(bid)); }
public void SeedItems(AuctionDbContext context) { Array enumValuesArray = Enum.GetValues(typeof(ItemType)); for (var i = 0; i < 10; i++) { var rand = this.random.Next(0, 7); var item = new Item { Title = string.Format("Item {0}", i), Author = string.Format("Pablo{0} Picasso{1}", i, i), Description = "Description" + i, Type = (ItemType)enumValuesArray.GetValue(rand) }; this.Items.Add(item); } context.Items.AddOrUpdate(this.Items.ToArray()); context.SaveChanges(); }
public void SeedAuctions(AuctionDbContext context) { for (var i = 0; i < 10; i++) { var randUser = this.random.Next(0, 3); var items = new List<Item> { this.Items[i] }; var bidders = this.Users; var auction = new Auction { Name = "Auction " + i, DateOfAuction = DateTime.UtcNow.AddHours(24 + (24 * i)), Active = false, InitialPrice = 10000 + 1000 * i, BidStep = 500, Items = items, //Creator = this.Users[randUser], Bidders = bidders }; this.Auctions.Add(auction); } context.Auctions.AddOrUpdate(this.Auctions.ToArray()); context.SaveChanges(); }
public void Save() { _dbContext.SaveChanges(); }
public void Save() { db.SaveChanges(); }