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 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 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 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 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 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); } }