public void ProcessRequest(HttpContext context) { if (!String.IsNullOrEmpty(context.Request.QueryString["ID"])) { byte[] binary; int id = Convert.ToInt32(context.Request.QueryString["ID"]); using (var ctx = new bazaEntities()) { binary = ctx.Auctions.Where(p => p.ID == id).Select(p => p.Image).FirstOrDefault(); } // list = list.Where(p => p.ID == 2); //var prop = list.GetType().GetProperty("Image"); //var obj = prop.GetValue(list); //byte[] binary = obj as byte[]; if (binary != null && binary.Length > 0) { context.Response.ContentType = "image/jpeg"; context.Response.BinaryWrite(binary); } } }
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 byte[] GetAuctionImageBytes(int AuctionId) { byte[] binary; using (var ctx = new bazaEntities()) { binary = ctx.Auctions.Where(p => p.ID == AuctionId).Select(p => p.Image).FirstOrDefault(); } return(binary); }
public IEnumerable <FiltersTable> GetColors() { List <FiltersTable> list; using (var ctx = new bazaEntities()) { list = ctx.FiltersTables.ToList <FiltersTable>(); } return(list); }
public List <Auction> GetAuctions() { List <Auction> list; using (var ctx = new bazaEntities()) { list = ctx.Auctions.ToList(); } return(list); }
public string GetCategoryNameById(int CategoryInt) { string CategoryRes; using (var ctx = new bazaEntities()) { CategoryRes = ctx.CategoriesTables.Where(p => p.ID == CategoryInt).Select(p => p.CategoryResourceName).SingleOrDefault(); } return(CategoryRes); }
public IEnumerable <CategoriesTable> GetCategoriesNames() { List <CategoriesTable> list; using (var ctx = new bazaEntities()) { list = ctx.CategoriesTables.ToList(); } return(list); }
public IEnumerable <Auction> GetAuctionById(int ID) { IEnumerable <Auction> list; using (var ctx = new bazaEntities()) { list = ctx.Auctions.ToList(); list = list.Where(p => p.ID == ID); } return(list); }
public byte[] GetUserImageBytes(string loggedUserName) { byte[] binary; using (var ctx = new bazaEntities()) { binary = (from userM in ctx.aspnet_Membership join userU in ctx.aspnet_Users on userM.UserId equals userU.UserId where userU.UserName == loggedUserName select userM.Image).FirstOrDefault(); } return(binary); }
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 IEnumerable <Aukcje.Auction> SelectItems() { IEnumerable <Auction> list = new List <Auction>(); using (var ctx = new bazaEntities()) { list = ctx.Auctions.ToList(); list = list.Where(p => p.ID == Convert.ToInt32(HttpContext.Current.Request.QueryString["ID"])); } foreach (Auction auction in list) { auction.Price = CurrencyConverter.ConvertMoney(auction.Price); } return(list); }
public IEnumerable <Auction> GetAuctionsByUser(string user) { IEnumerable <Aukcje.Auction> list; using (var ctx = new bazaEntities()) { list = from auction in ctx.Auctions join _user in ctx.aspnet_Users on auction.seller equals _user.UserName where (_user.UserName == user) select auction; list = list.ToList(); } return(list); }
public string ReturnFavouritesString(string UserName) { aspnet_Membership Users; string fav; 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(); fav = Users.FavouritesItems; } return(fav); }
public IEnumerable <string> GetBrands(int CategoryId) { List <string> list; List <Auction> AuctionsList; using (var ctx = new bazaEntities()) { AuctionsList = ctx.Auctions.Where(p => p.Brand != null).ToList(); } if (CategoryId > 0) { AuctionsList = AuctionsList.Where(p => p.Category == CategoryId).ToList(); } list = AuctionsList.Select(p => p.Brand).Distinct().OrderBy(p => p).ToList(); return(list); }
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 IEnumerable SelectAuctionsList() { IEnumerable <Auction> list; using (var ctx = new bazaEntities()) { list = ctx.Auctions.ToList(); } list = list.Where(p => p.status == "otwarte"); //catgory filtering if ((int)view.FilterCategory < 3) { list = list.Where(p => p.Category == (int)view.FilterCategory); // ((Aukcje.Site)this.Page.Master).changeValueInDropDowCategoryList((int)category); } if (!String.IsNullOrEmpty(view.SearchedItem)) { list = list.Where(p => (p.Title.IndexOf(view.SearchedItem, StringComparison.OrdinalIgnoreCase) >= 0)); // ((Aukcje.Site)this.Page.Master).changeValueInTextSearchBar(SearchedItem); } list = list.Where(p => p.Price >= view.FilterLowPrice && p.Price <= view.FilterHighPrice); //color filtering foreach (ListItem listItem in view.FilterColorCheckBoxList.Items) { if (listItem.Selected) { list = list.Where(p => (view.FilterColorCheckBoxList.Items[0].Selected ? p.Color == 0 : false) || (view.FilterColorCheckBoxList.Items[1].Selected ? p.Color == 1 : false) || (view.FilterColorCheckBoxList.Items[2].Selected ? p.Color == 2 : false) ); break; } } foreach (Auction auction in list) { auction.Price = CurrencyConverter.ConvertMoney(auction.Price); } return(list); }
public IEnumerable <UserWithRating> GetUserWithRating(string UserName) { IEnumerable <Aukcje.UserWithRating> list; using (var ctx = new bazaEntities()) { list = from p in ctx.aspnet_Users join d in ctx.aspnet_Membership on p.UserId equals d.UserId where p.UserName.Equals(UserName) select new UserWithRating() { currentUser = p, rate = d.Rating }; list = list.ToList(); } return(list); }
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(); } }
public IEnumerable <Models.CommentWithAuction> GetClosedAuctions(string UserName) { IEnumerable <Aukcje.Models.CommentWithAuction> list; IEnumerable <Aukcje.Auction> Auctions; IEnumerable <Aukcje.Comment> Comments; using (var ctx = new bazaEntities()) { Auctions = ctx.Auctions.ToList(); Comments = ctx.Comments.ToList(); } Auctions = Auctions.Where(p => p.seller.Equals(UserName) && p.status == "zakonczone"); list = from p in Auctions join c in Comments on p.commentID equals c.CommentID select new Models.CommentWithAuction() { aukcja = p, Comment = c, ConsumerName = "asd" }; return(list); }