예제 #1
0
        public Art Insert(string name, string artist, string description, string image, decimal startingbid, decimal purchaseprice)
        {
            using (AuctionDBContext db = new AuctionDBContext())
            {
                Art aTemp = new Art();
                Random r = new Random();
                aTemp.DateCreated = DateTime.Now;
                aTemp.Name = name;
                aTemp.Artist = artist;
                aTemp.Number = SetArtNumber();
                aTemp.Description = description;
                aTemp.Image = image;
                aTemp.StartingBid = startingbid;
                aTemp.PurchasePrice = purchaseprice;
                aTemp.Bids = null;

                try
                {
                    db.Arts.Add(aTemp);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    throw e;
                }

                return aTemp;
            }
        }
예제 #2
0
        public void DeleteArt(Art art)
        {
            if (art == null)
                throw new ArgumentNullException("art");
            using (AuctionDBContext db = new AuctionDBContext())
            {
                var dbArt = db.Arts.Single(x => x.Id == art.Id);

                //db.Arts.Attach(art);
                //db.Entry(art).State = EntityState.Deleted;
                db.Arts.Remove(dbArt);
                db.DebugDetectChanges();
                db.SaveChanges();
            }
        }
예제 #3
0
        public List<Bid> RetrieveBidsByArt(Art a)
        {
            List<Bid> bCollection = null;
            using (AuctionDBContext db = new AuctionDBContext())
            {
                try
                {
                    bCollection = db.Bids.Include(x => x.Member).Where(x => x.Art.Id == a.Id).OrderByDescending(x => x.DateTime).ToList();
                }
                catch (Exception e)
                {
                    throw e;
                }
            }

            return bCollection;
        }
        private void dgvArts_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            currentArt = (Art)dgvArts.CurrentRow.DataBoundItem;

            lblArtBid.Text = "Budgivning: Kunstværk nr. " + currentArt.Number.ToString();

            populatebids(currentArt.Number);
        }
예제 #5
0
 public void AddArt(Art art)
 {
     if (art == null)
         throw new ArgumentNullException("art");
     Arts.Add(art);
 }