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; } }
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(); } }
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); }
public void AddArt(Art art) { if (art == null) throw new ArgumentNullException("art"); Arts.Add(art); }