public ValidationResult_OSC AddCategory(OnlineShoppingCart.Model.ProductCategory category) { var result = new ValidationResult_OSC(); try { using (OnlineShoppingCartEntities entity = new OnlineShoppingCartEntities()) { OnlineShoppingCart.DataAccess.SQL.ProductCategory _category = new DataAccess.SQL.ProductCategory { Category = category.Category, IsActive = category.IsActive, CreatedOn = category.CreatedOn, UpdatedOn = category.UpdatedOn, CreatedByUserId = category.CreatedByUserID, UpdatedByUserId = category.UpdatedByUserID }; entity.ProductCategories.Add(_category); entity.SaveChanges(); result.Success = true; result.returnValue = Convert.ToString(_category.Id); result.Message = "Product category inserted successfully"; } return result; } catch (Exception ex) { result.Success = false; result.Message = ex.Message; return result; } }
public void ConvertToBusinessObject(out OnlineShoppingCart.Model.ProductImageInfo productImageInfo) { productImageInfo = new Model.ProductImageInfo { ProductId = this.ProductId, ImageFilePath = this.ImageFilePath, IsIndexImage = this.IsIndexImage }; }
public void ConvertToBusinessObject(out OnlineShoppingCart.Model.CartItem CartItemBO) { CartItemBO = new Model.CartItem { Id = this.Id, CartId=this.CartId, ProductId = this.ProductId, Quantity = this.Quantity, UnitPrice=this.UnitPrice, SubTotal = this.SubTotal, AddedDate=this.AddedDate }; }
public void ConvertToBusinessObject(out OnlineShoppingCart.Model.ProductCategory ProductCategory) { ProductCategory = new Model.ProductCategory { ID = this.Id, Category = this.Category, IsActive= this.IsActive, CreatedOn= this.CreatedOn, UpdatedOn= this.UpdatedOn, CreatedByUserID=this.CreatedByUserId, UpdatedByUserID= this.UpdatedByUserId }; }
public ValidationResult_OSC AddProduct(OnlineShoppingCart.Model.Product product) { var result = new ValidationResult_OSC(); try { using (OnlineShoppingCartEntities entity = new OnlineShoppingCartEntities()) { OnlineShoppingCart.DataAccess.SQL.Product _product = new DataAccess.SQL.Product { Model = product.Model, ProductCode = product.ProductCode, ProductName = product.ProductName, ProductDescription = product.ProductDescription, CategoryId = product.CategoryID, Brand = product.Brand, UnitPrice = product.UnitPrice, SKU = product.SKU, CurrentStock = product.CurrentStock, IsActive = product.IsActive, CreatedOn = product.CreatedOn, UpdatedOn = product.UpdatedOn, CreatedByUserId = product.CreatedByUserID, UpdatedByUserId = product.UpdatedByUserID }; entity.Products.Add(_product); entity.SaveChanges(); result.Success = true; result.returnValue = Convert.ToString(_product.Id); result.Message = "Product inserted successfully"; } return result; } catch (Exception ex) { result.Success = false; result.Message = ex.Message; return result; } }
public void ConvertToBusinessObject(out OnlineShoppingCart.Model.Product productBO) { productBO = new Model.Product { ID = this.Id, ProductCode = this.ProductCode, ProductName = this.ProductName, ProductDescription = this.ProductDescription, CategoryID = this.CategoryId, Brand = this.Brand, Model = this.Model, UnitPrice = this.UnitPrice, SKU = this.SKU, CurrentStock = this.CurrentStock, IsActive = this.IsActive, CreatedOn = this.CreatedOn, UpdatedOn = this.UpdatedOn.GetValueOrDefault(), CreatedByUserID = this.CreatedByUserId, UpdatedByUserID = this.UpdatedByUserId.GetValueOrDefault() //public byte[] ImageThumbNail = //byte[] ImageIndex = //List<byte[]> ImageOthers = }; }
public ValidationResult_OSC UpdateCategory(OnlineShoppingCart.Model.ProductCategory category) { var result = new ValidationResult_OSC(); try { using (OnlineShoppingCartEntities entity = new OnlineShoppingCartEntities()) { var _category = (from prodCat in entity.ProductCategories where prodCat.Id == category.ID select prodCat).First(); _category.Category = category.Category; _category.IsActive = category.IsActive; _category.CreatedOn = category.CreatedOn; _category.UpdatedOn = category.UpdatedOn; _category.CreatedByUserId = category.CreatedByUserID; _category.UpdatedByUserId = category.UpdatedByUserID; entity.SaveChanges(); result.Success = true; result.Message = "Product category updated successfully"; return result; } } catch (Exception ex) { result.Success = false; result.Message = ex.Message; return result; } }
public ValidationResult_OSC UpdateProduct(OnlineShoppingCart.Model.Product product) { var result = new ValidationResult_OSC(); try { using (OnlineShoppingCartEntities entity = new OnlineShoppingCartEntities()) { var _p = (from t in entity.Products where t.Id == product.ID select t).First(); _p.Model = product.Model; _p.ProductCode = product.ProductCode; _p.ProductName = product.ProductName; _p.ProductDescription = product.ProductDescription; _p.CategoryId = product.CategoryID; _p.Brand = product.Brand; _p.UnitPrice = product.UnitPrice; _p.SKU = product.SKU; _p.CurrentStock = product.CurrentStock; _p.IsActive = product.IsActive; _p.CreatedOn = product.CreatedOn; _p.UpdatedOn = product.UpdatedOn; _p.CreatedByUserId = product.CreatedByUserID; _p.UpdatedByUserId = product.UpdatedByUserID; entity.SaveChanges(); result.Success = true; result.Message = "Product updated successfully"; return result; } } catch (Exception ex) { result.Success = false; result.Message = ex.Message; return result; } }
public Result<List<OnlineShoppingCart.Model.Product>> GetProductList(OnlineShoppingCart.Model.Product product) { var result = new Result<List<OnlineShoppingCart.Model.Product>>(); result.Data = new List<Model.Product>(); using (OnlineShoppingCartEntities entity = new OnlineShoppingCartEntities()) { var listProd = (from prod in entity.Products.Include("ProductCategories") where ((product.ProductCode == null) || prod.ProductCode.Contains(product.ProductCode)) && ((product.ProductName == null) || prod.ProductName.Contains(product.ProductName)) && ((product.ProductDescription == null) || prod.ProductDescription.Contains(product.ProductDescription)) && (product.CategoryID == 0 || prod.CategoryId == product.CategoryID) && ((product.Brand == null) || prod.Brand.Contains(product.Brand)) && ((product.Model == null) || prod.Model.Contains(product.Model)) select new OnlineShoppingCart.Model.Product { ID = prod.Id, ProductCode = prod.ProductCode, ProductName = prod.ProductName, ProductDescription = prod.ProductDescription, CategoryID = prod.CategoryId, CategoryName = prod.ProductCategory.Category, Brand = prod.Brand, Model = prod.Model, UnitPrice = prod.UnitPrice, SKU = prod.SKU, CurrentStock = prod.CurrentStock, IsActive = prod.IsActive, CreatedOn = prod.CreatedOn, UpdatedOn = prod.UpdatedOn, CreatedByUserID = prod.CreatedByUserId, UpdatedByUserID = prod.UpdatedByUserId }).ToList(); if (listProd == null) { result.Success = false; result.Data = null; result.Message = "No product found for given search criteria"; } else { foreach (var _product in listProd) { DAL.ProductImage productImage = new ProductImage(); var resultProductImageList = productImage.GetListProductImageFilePath(_product.ID); if (resultProductImageList.Success) _product.ProductImageInfoList = resultProductImageList.Data; result.Data.Add(_product); } result.Success = true; } } return result; }