public bool DeleteProduct(product product) { try { productImage productImageObj = context.productImages.Where(x => x.productId == product.productId).SingleOrDefault <productImage>(); product productObj = (context.products.Where(x => x.productId == product.productId)).SingleOrDefault <product>(); context.productImages.Remove(productImageObj); context.products.Remove(productObj); context.SaveChanges(); return(true); } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } }
public bool AddImage(productImage productImage) { try { var obj = (context.productImages.Where(x => x.productId == productImage.productId)).SingleOrDefault(); obj.productImage1 = productImage.productImage1; obj.productImage2 = productImage.productImage2; obj.productImage3 = productImage.productImage3; obj.productImage4 = productImage.productImage4; context.SaveChanges(); return(true); } catch (Exception ex) { Console.WriteLine(ex.Message); return(false); } }