//updates ----------------------------------------------- #region Updates //Product Update ------------------------------------------------------------- public Boolean UpdateProduct(Product prod, string lub)//Product,LastUpdateBy { DEMO_PRODUCT_INFO result = (from p in db.DEMO_PRODUCT_INFO where p.PRODUCT_ID == prod.Product_ID select p).SingleOrDefault(); result.PRODUCT_NAME = prod.Product_Name; result.PRODUCT_DESCRIPTION = prod.Product_Description; result.CATEGORY = prod.Category; result.PRODUCT_AVAIL = prod.Product_Avail; result.LIST_PRICE = prod.List_Price; //result.PRODUCT_IMAGE = prod.Product_Image; //result.MIMETYPE = prod.MIMETYPE; //result.FILENAME = prod.Filename; //result.IMAGE_LAST_UPDATE = prod.Image_Last_Update; result.TAGS = prod.Tags; result.SALE_PRICE = prod.Sale_Price; result.SALE_BEGIN = prod.Sale_Begin; result.SALE_END = prod.Sale_End; result.FRONTEND_ID = prod.Frontend_ID; result.MANUFACTURER_ID = prod.Manufaturer_ID; result.LAST_UPDATED_BY = lub; try { db.SaveChanges(); return(true); } catch (DbUpdateException ex) { return(false); } }
public Boolean UpdateProductMID(decimal pid, decimal?mid, string lub) //ProductID,ManufacturerID,LastUpdateBy { DEMO_PRODUCT_INFO result = (from p in db.DEMO_PRODUCT_INFO where p.PRODUCT_ID == pid select p).SingleOrDefault(); result.MANUFACTURER_ID = mid; result.LAST_UPDATED_BY = lub; try { db.SaveChanges(); return(true); } catch (DbUpdateException ex) { return(false); } }
public Boolean UpdateProductFID(decimal pid, decimal?fid, string lub) //ProductID,FrondEndID,LastUpdateBy { DEMO_PRODUCT_INFO result = (from p in db.DEMO_PRODUCT_INFO where p.PRODUCT_ID == pid select p).SingleOrDefault(); result.FRONTEND_ID = fid; result.LAST_UPDATED_BY = lub; try { db.SaveChanges(); return(true); } catch (DbUpdateException ex) { return(false); } }
//Inserts --------------------------------------------------------------- #region Inserts public void AddProduct(Product p) { DEMO_PRODUCT_INFO pt = new DEMO_PRODUCT_INFO(); pt.PRODUCT_ID = p.Product_ID; pt.PRODUCT_NAME = p.Product_Name; pt.PRODUCT_DESCRIPTION = p.Product_Description; pt.CATEGORY = p.Category; pt.PRODUCT_AVAIL = p.Product_Avail; pt.LIST_PRICE = p.List_Price; pt.PRODUCT_IMAGE = p.Product_Image; pt.MIMETYPE = p.MIMETYPE; pt.FILENAME = p.Filename; pt.IMAGE_LAST_UPDATE = p.Image_Last_Update; pt.TAGS = p.Tags; pt.SALE_PRICE = p.Sale_Price; pt.SALE_BEGIN = p.Sale_Begin; pt.SALE_END = p.Sale_End; pt.FRONTEND_ID = p.Frontend_ID; pt.MANUFACTURER_ID = p.Manufaturer_ID; pt.LAST_MODIFIED_DATE = p.Last_Updated; pt.LAST_UPDATED_BY = p.Last_Updated_By; db.DEMO_PRODUCT_INFO.Add(pt); try { db.SaveChanges(); } catch (DbEntityValidationException dbEx) { foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); } } } }