Exemplo n.º 1
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            AuctionsService         auctionService = new AuctionsService();
            SharedService           sharedService  = new SharedService();
            AuctionDetailsViewModel model          = new AuctionDetailsViewModel();

            model.Auction    = auctionService.GetAuctionByID(id);
            model.BidsAmount = model.Auction.InitialPrice + model.Auction.Bids.Sum(x => x.BiddingRate);
            var latestbidder = model.Auction.Bids.OrderByDescending(x => x.TimeStamp).FirstOrDefault();

            model.LatestBidder = latestbidder != null ? latestbidder.User : null;
            model.EntityID     = (int)EntityEnums.Auction;
            model.Comments     = sharedService.GetComments((int)EntityEnums.Auction, model.Auction.ID);
            if (model == null)
            {
                return(RedirectToAction("Error", "Home"));
            }
            try
            {
                Auction auction = new Auction();
                auction = model.Auction;
                auction.InitialPrice    = model.Auction.InitialPrice + model.Auction.Bids.Sum(x => x.BiddingRate);
                db.Entry(auction).State = EntityState.Modified;
                db.SaveChanges();
            }
            catch {
            }
            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Include = "ID,Name,Description")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Exemplo n.º 3
0
        public bool AddBid(Bid bid)
        {
            AmigosAuctionContext context = new AmigosAuctionContext();

            context.Bids.Add(bid);
            return(context.SaveChanges() > 0);
        }
Exemplo n.º 4
0
 public void DeleteAuction(Auction auction)
 {
     context = new AmigosAuctionContext();
     context.Entry(auction).State = System.Data.Entity.EntityState.Deleted;
     //context.Auctions.Remove(auction);
     context.SaveChanges();
 }
Exemplo n.º 5
0
 public bool LeaveComment(Comment comment)
 {
     context = new AmigosAuctionContext();
     //Need to add EnityFramework from NuggetPackageManager
     context.Comments.Add(comment);
     return(context.SaveChanges() > 0);
 }
Exemplo n.º 6
0
 public int SavePicture(Picture picture)
 {
     context = new AmigosAuctionContext();
     //Need to add EnityFramework from NuggetPackageManager
     context.Pictures.Add(picture);
     context.SaveChanges();
     return(picture.ID);
 }
Exemplo n.º 7
0
        public ActionResult DeleteConfirmed(int id)
        {
            Comment comment = db.Comments.Find(id);

            db.Comments.Remove(comment);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 8
0
 //save
 public void SaveCategory(Category category)
 {
     try
     {
         context = new AmigosAuctionContext();
         //Need to add EnityFramework from NuggetPackageManager
         context.Categories.Add(category);
         context.SaveChanges();
     }
     catch (Exception e)
     {
         Console.Write(e.Message);
     }
 }
Exemplo n.º 9
0
 public void SaveAuction(Auction auction)
 {
     try
     {
         context = new AmigosAuctionContext();
         //Need to add EnityFramework from NuggetPackageManager
         context.Auctions.Add(auction);
         context.SaveChanges();
     }
     catch (Exception e)
     {
         Console.Write(e.Message);
     }
 }
Exemplo n.º 10
0
 //Delete
 public void DeleteCategory(Category category)
 {
     context = new AmigosAuctionContext();
     context.Entry(category).State = System.Data.Entity.EntityState.Deleted;
     context.SaveChanges();
 }
Exemplo n.º 11
0
 public void UpdateAuction(Auction auction)
 {
     context = new AmigosAuctionContext();
     context.Entry(auction).State = System.Data.Entity.EntityState.Modified;
     context.SaveChanges();
 }