public List <Category> GetCategorise() { using (QuiBidsEntities1 db = new QuiBidsEntities1()) { return(db.Categories.ToList()); } }
public List <Product> GetAllProduct() { using (QuiBidsEntities1 db = new QuiBidsEntities1()) { return(db.Products.ToList()); } }
public Category GetCategoryById(int CateId) { using (QuiBidsEntities1 db = new QuiBidsEntities1()) { return(db.Categories.Where(a => a.Id == CateId).FirstOrDefault()); } }
public List <User> GetUsers() { using (QuiBidsEntities1 db = new QuiBidsEntities1()) { return(db.Users.ToList()); } }
public List <Auction> GetAuctions() { using (QuiBidsEntities1 db = new QuiBidsEntities1()) { return(db.Auctions.ToList()); } }
public User GetUserById(int UserId) { using (QuiBidsEntities1 db = new QuiBidsEntities1()) { return(db.Users.Where(a => a.Id == UserId).FirstOrDefault()); } }
public List <AuctionViewModel> GetViewModel() { using (QuiBidsEntities1 db = new QuiBidsEntities1()) { var q = (from p in db.Auctions join im in db.Images on p.ProductId equals im.ProductId into img from image in img.DefaultIfEmpty() group new { p, image } by p.Id into gr select new { Auction_Time = gr.FirstOrDefault().p.Auction_Time, Id = gr.FirstOrDefault().p.Id, IsActive = gr.FirstOrDefault().p.IsActive, Image = gr.FirstOrDefault().image, Title = gr.FirstOrDefault().p.Product.Name }).OrderByDescending(x => x.Auction_Time).ToList(); var q2 = q.Select(x => new AuctionViewModel { Id = x.Id, Str_AuctionTime = ConvertAuctionTimeToStr(x.Auction_Time), Image = x.Image != null? x.Image.ImageTitle:"", IsActive = x.IsActive, Title = x.Title }).ToList(); return(q2); } }
public Auction GetAuctionById(int id) { using (QuiBidsEntities1 db = new QuiBidsEntities1()) { return(db.Auctions.Find(id)); } }
public Product GetProductById(int ProductId) { using (QuiBidsEntities1 db = new QuiBidsEntities1()) { return(db.Products.Where(a => a.Id == ProductId).FirstOrDefault()); } }
public bool DeleteCategory(int CategoryId) { using (QuiBidsEntities1 db = new QuiBidsEntities1()) { db.Categories.Remove(GetCategoryById(CategoryId)); return(Convert.ToBoolean(db.SaveChanges())); } }
public bool DeleteProduct(int ProductId) { using (QuiBidsEntities1 db = new QuiBidsEntities1()) { var s = GetProductById(ProductId); db.Products.Remove(GetProductById(ProductId)); return(Convert.ToBoolean(db.SaveChanges())); } }
public bool EditeCategory(int CateId, string CName) { using (QuiBidsEntities1 db = new QuiBidsEntities1()) { var EC = db.Categories.Where(a => a.Id == CateId).FirstOrDefault(); EC.CategoryName = CName; EC.ParentCategoryId = 1; return(Convert.ToBoolean(db.SaveChanges())); } }
public bool ChangeStatus(int id) { using (QuiBidsEntities1 db = new QuiBidsEntities1()) { var auction = db.Auctions.Find(id); auction.IsActive = auction.IsActive? false : true; db.Entry(auction).State = System.Data.Entity.EntityState.Modified; return(db.SaveChanges() == 1?true:false); } }
public List <ProductForDropDown> GetProForDop() { using (QuiBidsEntities1 db = new QuiBidsEntities1()) { return(db.Products.Select(x => new ProductForDropDown { Id = x.Id, Name = x.Name }).ToList()); } }
public List <CategoryViewModel> GetCategoryViewModel() { using (QuiBidsEntities1 db = new QuiBidsEntities1()) { return(db.Categories.Select(x => new CategoryViewModel { Id = x.Id, CategoryName = x.CategoryName }).ToList()); } }
public bool AddCategory(CategoryViewModel AC) { using (QuiBidsEntities1 db = new QuiBidsEntities1()) { Category tb = new Category(); tb.Id = AC.Id; tb.CategoryName = AC.CategoryName; tb.ParentCategoryId = AC.ParentCategoryId; db.Categories.Add(tb); return(Convert.ToBoolean(db.SaveChanges())); } }
public int GetAdminId(string Username) { using (QuiBidsEntities1 db = new QuiBidsEntities1()) { var q = db.Users.Where(a => a.Email == Username).FirstOrDefault(); if (q != null) { return(q.Id); } else { return(0); } } }
public bool AddAuction(AuctionAddViewModel model) { using (QuiBidsEntities1 db = new QuiBidsEntities1()) { var auction = new Auction { Auction_Time = model.Auction_Time, BuyPrice = model.BuyPrice, Close_Time = model.Close_Time, IsActive = true, ProductId = model.ProductId, }; db.Auctions.Add(auction); return(db.SaveChanges() == 1 ? true : false); } }
public bool Login(string Email, string PWord) { using (QuiBidsEntities1 db = new QuiBidsEntities1()) { var q = db.Users.Where(a => a.Email == Email && a.Password == PWord).FirstOrDefault(); if (q != null) { return(true); } else { return(false); } } }
public bool UpDateproduct(ProductViewModel UDP) { using (QuiBidsEntities1 db = new QuiBidsEntities1()) { var Model = GetProductById(UDP.Id); if (Model == null) { return(false); } Model.Brand = UDP.Brand; Model.Name = UDP.Name; Model.Price = UDP.Price; Model.Image = UDP.Img; Model.Model_Year = UDP.Model_Year; Model.Stock = UDP.Stock; db.Entry(Model).State = System.Data.Entity.EntityState.Modified; return(Convert.ToBoolean(db.SaveChanges())); } }
public bool Addproduct(MainViewModel model) { var result = false; //using (TransactionScope scope = new TransactionScope()) //{ using (QuiBidsEntities1 db = new QuiBidsEntities1()) { Product product = new Product { Brand = model.Brand, CatId = model.Catid, Model_Year = model.Model_Year, Name = model.Name, Price = model.Price, Stock = model.Stock }; db.Products.Add(product); db.SaveChanges(); List <Image> listImage = new List <Image>(); foreach (var item in model.Img) { Image listImg = new Image { ImageURL = item, ProductId = product.Id }; db.Images.Add(listImg); result = db.SaveChanges() == 1 ? true : false; //listImage.Add(listImg); } //db.Image.AddRange(listImage); //var d = db.SaveChanges(); //return db.SaveChanges() == 1 ? true : false; //} //scope.Complete(); } return(result); }
public bool AddAdmin(UserViewModel model) { var result = false; using (QuiBidsEntities1 db = new QuiBidsEntities1()) { var pass = new Helpers().Encryption(model.PassWord); User tb = new User { Email = model.Email, Password = new Helpers().Encryption(model.PassWord), Fname = model.FirstName, Lname = model.LastName, Address = model.Address, Mobile = model.PhonNumber, //Image = model.Imageurl }; db.Users.Add(tb); result = db.SaveChanges() == 1 ? true : false; return(result); } }