public void AddNewItem() { try { Auction currentItem = new Auction() { Title = view.AuctionName, Category = (int)view.AuctionCategoryType, Color = (int)view.AuctionColor, Description = view.AuctionDescrition, Price = view.AuctionPrice, seller = System.Web.Security.Membership.GetUser().UserName, status = "otwarte", Image = view.AuctionImageBytes }; using (var ctx = new bazaEntities()) { ctx.Auctions.Add(currentItem); ctx.SaveChanges(); } } catch { view.ControlLabel.Visible = true; view.ControlLabel.Text = "Somenthing went wrong try again lter"; view.ControlLabel.Font.Size = 32; } ClearLabels(); view.ControlLabel.Text = "Congrats! Your Item was succesfully added"; view.ControlLabel.Font.Size = 32; }
public void AddAuctions(Auction auc) { using (var ctx = new bazaEntities()) { ctx.Auctions.Add(auc); ctx.SaveChanges(); } }
public void AddColor(FiltersTable newColor) { using (var ctx = new bazaEntities()) { ctx.FiltersTables.Add(newColor); ctx.SaveChanges(); } }
public void DeleteAuction(int Id) { using (var ctx = new bazaEntities()) { var obj = ctx.Auctions.SingleOrDefault(p => p.ID == Id); ctx.Auctions.Remove(obj); ctx.SaveChanges(); } }
public void UpdateUserPicture(string UserName, byte[] PictureBytes) { using (var ctx = new bazaEntities()) { aspnet_Membership user = (from userU in ctx.aspnet_Users join userM in ctx.aspnet_Membership on userU.UserId equals userM.UserId where userU.UserName == UserName select userM).FirstOrDefault(); user.Image = PictureBytes; ctx.SaveChanges(); } }
public void UpdateAuction(Aukcje.Auction objAuction, byte[] bytes) { int a = objAuction.ID; using (var ctx = new bazaEntities()) { var updatedauction = ctx.Auctions.FirstOrDefault(p => p.ID == a); updatedauction.Title = objAuction.Title; updatedauction.Description = objAuction.Description; updatedauction.Price = objAuction.Price; if (bytes != null) { updatedauction.Image = bytes; } ctx.SaveChanges(); } }
public void AddToFavourites(string UserName, int Id) { aspnet_Membership Users; using (var ctx = new bazaEntities()) { Users = (from _User in ctx.aspnet_Users join tempUser in ctx.aspnet_Membership on _User.UserId equals tempUser.UserId where _User.UserName == UserName select tempUser).First(); string fav = Users.FavouritesItems; if (string.IsNullOrEmpty(fav) || fav.IndexOf(Id.ToString() + '|') < 0) { fav += $"{Id.ToString()}|"; } Users.FavouritesItems = fav; ctx.SaveChanges(); } }