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 ValidationResult_OSC DeleteCategory(int categoryId) { var result = new ValidationResult_OSC(); try { using (OnlineShoppingCartEntities entity = new OnlineShoppingCartEntities()) { var category = (from prodCat in entity.ProductCategories where prodCat.Id == categoryId select prodCat).First(); entity.ProductCategories.Remove(category); entity.SaveChanges(); result.Success = true; result.Message = "Product deleted successfully"; return result; } } catch (Exception ex) { result.Success = false; result.Message = ex.Message; return result; } }
public ValidationResult_OSC AddListProductImageFilePath(List<OnlineShoppingCart.Model.ProductImageInfo> lstProductImageInfo) { var result = new ValidationResult_OSC(); try { using (OnlineShoppingCartEntities entity = new OnlineShoppingCartEntities()) { foreach (var productImageInfo in lstProductImageInfo) { OnlineShoppingCart.DataAccess.SQL.ProductImageFilePath _product = new DataAccess.SQL.ProductImageFilePath { ProductId = productImageInfo.ProductId, ImageFilePath = productImageInfo.ImageFilePath, IsIndexImage = productImageInfo.IsIndexImage }; entity.ProductImageFilePaths.Add(_product); } entity.SaveChanges(); result.Success = true; result.Message = "Product image path information inserted successfully"; } return result; } catch (Exception ex) { result.Success = false; result.Message = ex.Message; return result; } }
public ValidationResult_OSC DeletProduct(int productId) { var result = new ValidationResult_OSC(); try { using (OnlineShoppingCartEntities entity = new OnlineShoppingCartEntities()) { var product = (from t in entity.Products where t.Id == productId select t).First(); entity.Products.Remove(product); entity.SaveChanges(); result.Success = true; result.Message = "Product deleted successfully"; return result; } } catch (Exception ex) { result.Success = false; result.Message = ex.Message; return result; } }
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 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; } }