public BaseController() { EcommerceEntities entity = new EcommerceEntities(); Repository = new UnitOfWork(entity); Mapper = AutoMapperConfig.MapperConfiguration.CreateMapper(); }
public static List <ProductAtrributeOptionsViewModel> GetProductAtrributeOptionById(int id) { ResponseViewModel <ProductAtrributeOptionsViewModel> viewModel = new ResponseViewModel <ProductAtrributeOptionsViewModel>(); List <ProductAtrributeOptionsViewModel> attributeOptionViewModelList = new List <ProductAtrributeOptionsViewModel>(); using (EcommerceEntities entities = new EcommerceEntities()) { List <ProductAttributeOption> options = new List <ProductAttributeOption>(); List <ProductAttribute> attributes = new List <ProductAttribute>(); List <OptionList> optionsList = null; attributes = entities.ProductAttributes.Where(entry => entry.ProductSubCategoryID == id).ToList(); foreach (var attribute in attributes) { ProductAtrributeOptionsViewModel attributeOptionViewModel = new ProductAtrributeOptionsViewModel(); attributeOptionViewModel.attributeName = attribute.Name; attributeOptionViewModel.attributeId = Convert.ToInt32(attribute.ID); options = entities.ProductAttributeOptions.Where(entry => entry.ProductAtrributeID == attribute.ID).ToList(); if (options != null) { optionsList = new List <OptionList>(); foreach (var option in options) { OptionList optionViewModel = new OptionList(); optionViewModel.optionName = option.Value; optionViewModel.optionId = Convert.ToInt32(option.ID); optionsList.Add(optionViewModel); } } attributeOptionViewModel.optionList = optionsList; attributeOptionViewModelList.Add(attributeOptionViewModel); } return(attributeOptionViewModelList); } }
public HeaderModel() { EcommerceEntities db = new EcommerceEntities(); this.HorizontalCategories = db.CATEGORIEs.Where(x => x.CATEGORIE_TYPE == 2 && x.CATEGORIE_ROOT == null).ToList(); this.VerticalCategories = db.CATEGORIEs.Where(x => x.CATEGORIE_TYPE == 1 && x.CATEGORIE_ROOT == null).ToList(); }
public IList <IItemDTO> GetAllSubCategoryItems(int categoryId) { IList <IItemDTO> employeeDTOList = new List <IItemDTO>(); IItemDTO employeeDTO = null; using (EcommerceEntities employeePortalEntities = new EcommerceEntities()) { try { var employeeEntity = (employeePortalEntities.Items).Where(item => item.SubCategotyId == categoryId); foreach (var emp in employeeEntity) { employeeDTO = (IItemDTO)DTOFactory.Instance.Create(DTOType.Item); EntityConverter.FillDTOFromEntity(emp, employeeDTO); employeeDTOList.Add(employeeDTO); } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } } return(employeeDTOList); }
public static ResponseViewModel <PageViewModel <GetAttributeList_Result> > GetProductAttributeList(SearchViewModel searchViewModel) { using (EcommerceEntities entities = new EcommerceEntities()) { ResponseViewModel <PageViewModel <GetAttributeList_Result> > ViewModel = new ResponseViewModel <PageViewModel <GetAttributeList_Result> >(); List <GetAttributeList_Result> getProductResult = new List <GetAttributeList_Result>(); PageViewModel <GetAttributeList_Result> pageViewModel = new PageViewModel <GetAttributeList_Result>(); getProductResult = entities.GetAttributeList(searchViewModel.pageIndex, searchViewModel.pageSize, searchViewModel.searchText == "" ? null : searchViewModel.searchText, searchViewModel.sortOrder, searchViewModel.sortColoumn).ToList(); pageViewModel.Data = getProductResult; pageViewModel.totalRecords = getProductResult.Count(); if (((pageViewModel.totalRecords % searchViewModel.pageSize) == 0)) { if (pageViewModel.totalRecords < searchViewModel.pageSize) { pageViewModel.totalPage = 1; } else { pageViewModel.totalPage = (pageViewModel.totalRecords / searchViewModel.pageSize); } } else { pageViewModel.totalPage = (pageViewModel.totalRecords / 10) + 1; } ViewModel.Data = pageViewModel; return(ViewModel); } }
public static void GenerateOrder() { using (EcommerceEntities entites = new EcommerceEntities()) { HttpRequest httpRequest = HttpContext.Current.Request; List <OrderItemViewModel> orderItems = JsonConvert.DeserializeObject <List <OrderItemViewModel> >(httpRequest["orderItems"]); Order order = new Order(); order.CustomerID = Convert.ToInt16(httpRequest["custmerId"]); order.GrandTotal = Convert.ToInt16(httpRequest["GrandTotal"]); order.Date = DateTime.UtcNow; OrderStatu orderStatus = entites.OrderStatus.FirstOrDefault(); order.OrderStatusID = orderStatus.ID; foreach (var orderItem in orderItems) { order.OrderItems.Add(new OrderItem { ItemName = orderItem.itemName, ItemDiscount = orderItem.itemDiscount, ItemImage = orderItem.itemImage, ItemPrice = Convert.ToInt16(orderItem.itemPrice), ItemQuentity = Convert.ToInt16(orderItem.itemQuentity), ProductID = orderItem.productId }); } entites.Orders.Add(order); entites.SaveChanges(); } }
public static ResponseViewModel <ProductAttribute> AddProductAttribute(ProductAttributeViewModel viewModel) { ResponseViewModel <ProductAttribute> responseViewModel = new ResponseViewModel <ProductAttribute>(); ProductAttribute productAtribute = new ProductAttribute(); productAtribute.Name = viewModel.attributeName; productAtribute.ProductCategoryID = viewModel.productCategoryId; productAtribute.ProductSubCategoryID = viewModel.productSubCategoryId; using (EcommerceEntities entities = new EcommerceEntities()) { if (CheckDuplicate(productAtribute)) { responseViewModel.errorViewModel = new ErrorViewModel(); responseViewModel.errorViewModel.statusCode = 400; } else { entities.ProductAttributes.Add(productAtribute); entities.SaveChanges(); ProductAttributeManager.AddOption(viewModel.options, productAtribute.ID); responseViewModel.Data = productAtribute; entities.SaveChanges(); } } return(responseViewModel); }
public bool EditSubCategory(ISubCategoriesDTO sub) { bool retVal = false; using (EcommerceEntities employeePortalEntities = new EcommerceEntities()) { try { var employeeEntity = employeePortalEntities.SubCategories.FirstOrDefault(employee => employee.SubCategotyId == sub.SubCategotyId); if (employeeEntity != null) { employeeEntity.CategotyId = sub.CategotyId; employeeEntity.SubCategoryName = sub.SubCategoryName; employeePortalEntities.SaveChanges(); retVal = true; } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } } return(retVal); }
public ICategoriesDTO editCategory(ICategoriesDTO categoryDTO) { ICategoriesDTO retVal = null; try { using (var database = new EcommerceEntities()) { var category = database.Categories.Where(c => c.CategotyId == categoryDTO.CategotyId).FirstOrDefault(); if (category != null) { category.CategoryName = categoryDTO.CategoryName; database.SaveChanges(); retVal = (ICategoriesDTO)DTOFactory.Instance.Create(DTOType.Category, null); EntityConverter.FillDTOFromEntity(category, retVal); } } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } return(retVal); }
public IList <ICategoriesDTO> GetAllCategories() { IList <ICategoriesDTO> employeeDTOList = new List <ICategoriesDTO>(); ICategoriesDTO employeeDTO = null; using (EcommerceEntities employeePortalEntities = new EcommerceEntities()) { try { var employeeEntity = (employeePortalEntities.Categories); foreach (var emp in employeeEntity) { employeeDTO = (ICategoriesDTO)DTOFactory.Instance.Create(DTOType.Category); EntityConverter.FillDTOFromEntity(emp, employeeDTO); employeeDTOList.Add(employeeDTO); } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } } return(employeeDTOList); }
public static Boolean CheckDuplicate(Product product) { using (EcommerceEntities entities = new EcommerceEntities()) { return entities.Products.Any(entry => entry.Name == product.Name && entry.ProductCateogoryID == product.ProductCateogoryID; } }
public bool removeCategory(int categoryId) { bool retVal = false; try { using (var database = new EcommerceEntities()) { var categoryEntities = database.Categories; Category category = categoryEntities.Where(i => i.CategotyId == categoryId).FirstOrDefault(); if (category != null) { categoryEntities.Remove(category); database.SaveChanges(); retVal = true; } } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } return(retVal); }
public static Boolean CheckDuplicateOption(int optionID,long productId) { using (EcommerceEntities entities = new EcommerceEntities()) { return entities.Product_Attribute.Any(entry => entry.OptionID == optionID && entry.ProductID == productId); } }
public static ResponseViewModel<List<GetProductWiseOrders_Result>> GetProductWiseOrder() { ResponseViewModel<List<GetProductWiseOrders_Result>> response = new ResponseViewModel<List<GetProductWiseOrders_Result>>(); using (EcommerceEntities entities = new EcommerceEntities()) { /*List<Product> products = new List<Product>(); products = entities.Products.ToList(); foreach(var product in products) { ProductWiseOrderViewModel viewModel = new ProductWiseOrderViewModel(); viewModel.ProductName = product.Name; viewModel.NoOfOrders = 0; viewModelList.Add(viewModel); } List<GetProductWiseOrders_Result> result = entities.GetProductWiseOrders().ToList(); foreach (var product in viewModelList) { foreach (var singleResult in result) { if (singleResult.ProductName == product.ProductName) { product.NoOfOrders = Convert.ToInt32(singleResult.NoOfOrders); } product.OrderCount = Convert.ToInt32(singleResult.OrderCount); product.ProductCount = Convert.ToInt32(singleResult.ProductCount); product.CustomerCount = Convert.ToInt32(singleResult.CustomerCount); } }*/ List<GetProductWiseOrders_Result> result = entities.GetProductWiseOrders().ToList(); response.Data = result; return response; } }
public bool removeItem(int itemId) { bool retVal = false; try { using (var database = new EcommerceEntities()) { var itemEntities = database.Items; Item item = itemEntities.Where(i => i.ItemId == itemId).FirstOrDefault(); if (item != null) { itemEntities.Remove(item); database.SaveChanges(); retVal = true; } } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } return(retVal); }
public static List <Tax> GetTax() { using (EcommerceEntities entities = new EcommerceEntities()) { List <Tax> taxValues = entities.Taxes.ToList(); return(taxValues); } }
public ClienteView(Cliente cliente, ClienteListView clienteList, EcommerceEntities bancoDados) { this.cliente = cliente; InitializeComponent(); DataContext = this; this.clienteList = clienteList; this.bancoDados = bancoDados; }
public static int GetProductCount() { using (EcommerceEntities entities = new EcommerceEntities()) { int productCount = entities.Products.Count(); return productCount; } }
public static List <Customer> GetCustomers() { using (EcommerceEntities entities = new EcommerceEntities()) { List <Customer> Customers = entities.Customers.ToList(); return(Customers); } }
/* public static List<Product_BasketItem_Join> GetProductByBasket() { using (EcommerceEntities entities = new EcommerceEntities()) { List<Product_BasketItem_Join> products = entities.Products.Join(entities.BasketItems, product => product.ID, basketItem => basketItem.productId, (product, basketItem) => new Product_BasketItem_Join() { productName = product.Name, productPrice = product?.Price , productQuentity = basketItem.quantity }).Where(basketItem => basketItem.productQuentity == 3).ToList(); return products; } }*/ public static List<IGrouping<string, Product>> GetProductsByGroup() { using (EcommerceEntities entities = new EcommerceEntities()) { List<IGrouping<string, Product>> products = entities.Products.GroupBy(product => product.Description).ToList(); return products; } }
public static List<Product> GetProductsByOrder() { using (EcommerceEntities entities = new EcommerceEntities()) { List<Product> products = entities.Products.OrderBy(product => product.Name).ToList(); return products; } }
public static void AddCustomer(Customer customer) { using (EcommerceEntities entities = new EcommerceEntities()) { entities.Customers.Add(customer); entities.SaveChanges(); } }
public static List<GetProduct_Result> GetProducts() { using (EcommerceEntities entities = new EcommerceEntities()) { List<GetProduct_Result> products = entities.GetProduct().ToList(); return products; } }
public HttpResponseMessage Get() { EcommerceEntities ecommerceEntities = new EcommerceEntities(); var allUsers = from user in ecommerceEntities.RegisterUsers.AsEnumerable() select user; return(Request.CreateResponse(HttpStatusCode.OK, allUsers)); }
public static void DeleteProductOptionById(int id) { using (EcommerceEntities entities = new EcommerceEntities()) { ProductAttributeOption propductAttributeOption = entities.ProductAttributeOptions.Where(entry => entry.ID == id).FirstOrDefault(); entities.ProductAttributeOptions.Remove(propductAttributeOption); entities.SaveChanges(); } }
public static void DeleteProductSubCategory(int id) { using (EcommerceEntities entities = new EcommerceEntities()) { ProductSubCategory productSubCategory = entities.ProductSubCategories.Where(entry => entry.ID == id).FirstOrDefault(); entities.ProductSubCategories.Remove(productSubCategory); entities.SaveChanges(); } }
public static void DeleteCustomer(int id) { using (EcommerceEntities entities = new EcommerceEntities()) { Customer customer = entities.Customers.Where(entry => entry.ID == id).FirstOrDefault(); entities.Customers.Remove(customer); entities.SaveChanges(); } }
public static void DeleteOrderStatus(int id) { using (EcommerceEntities entities = new EcommerceEntities()) { OrderStatu orderStatus = entities.OrderStatus.Where(entry => entry.ID == id).FirstOrDefault(); entities.OrderStatus.Remove(orderStatus); entities.SaveChanges(); } }
public static void DeleteProductAttribute(int id) { using (EcommerceEntities entities = new EcommerceEntities()) { ProductAttribute productAttribute = entities.ProductAttributes.Where(entry => entry.ID == id).FirstOrDefault(); ProductAttributeManager.DeleteOptionByAttributeId(productAttribute.ID); entities.ProductAttributes.Remove(productAttribute); entities.SaveChanges(); } }
public static ResponseViewModel <List <GetCustomerById_Result> > GetCustomersById(int id) { using (EcommerceEntities entities = new EcommerceEntities()) { ResponseViewModel <List <GetCustomerById_Result> > response = new ResponseViewModel <List <GetCustomerById_Result> >(); List <GetCustomerById_Result> result = entities.GetCustomerById(id).ToList(); response.Data = result; return(response); } }
public int addSubCategory(ISubCategoriesDTO category) { int retVal = default(int); using (EcommerceEntities employeePortalEntities = new EcommerceEntities()) { try { SubCategory employee = new SubCategory(); EntityConverter.FillEntityFromDTO(category, employee); SubCategory addedEmployee = employeePortalEntities.SubCategories.Add(employee); employeePortalEntities.SaveChanges(); retVal = addedEmployee.SubCategotyId; } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } } return retVal; }
public IList<IItemDTO> GetAllSubCategoryItems(int categoryId) { IList<IItemDTO> employeeDTOList = new List<IItemDTO>(); IItemDTO employeeDTO = null; using (EcommerceEntities employeePortalEntities = new EcommerceEntities()) { try { var employeeEntity = (employeePortalEntities.Items).Where(item => item.SubCategotyId == categoryId); foreach (var emp in employeeEntity) { employeeDTO = (IItemDTO)DTOFactory.Instance.Create(DTOType.Item); EntityConverter.FillDTOFromEntity(emp, employeeDTO); employeeDTOList.Add(employeeDTO); } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } } return employeeDTOList; }
public bool deleteSubCategory(int categoryId) { bool retVal = false; using (EcommerceEntities employeePortalEntities = new EcommerceEntities()) { try { SubCategory cat = employeePortalEntities.SubCategories.Where(category => category.SubCategotyId == categoryId).FirstOrDefault(); employeePortalEntities.SubCategories.Remove(cat); employeePortalEntities.SaveChanges(); retVal = true; } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } } return retVal; }
public ICategoriesDTO editCategory(ICategoriesDTO categoryDTO) { ICategoriesDTO retVal = null; try { using (var database = new EcommerceEntities()) { var category = database.Categories.Where(c => c.CategotyId == categoryDTO.CategotyId).FirstOrDefault(); if (category != null) { category.CategoryName = categoryDTO.CategoryName; database.SaveChanges(); retVal = (ICategoriesDTO)DTOFactory.Instance.Create(DTOType.Category, null); EntityConverter.FillDTOFromEntity(category, retVal); } } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } return retVal; }
public bool EditSubCategory(ISubCategoriesDTO sub) { bool retVal = false; using (EcommerceEntities employeePortalEntities = new EcommerceEntities()) { try { var employeeEntity = employeePortalEntities.SubCategories.FirstOrDefault(employee => employee.SubCategotyId == sub.SubCategotyId); if (employeeEntity != null) { employeeEntity.CategotyId = sub.CategotyId; employeeEntity.SubCategoryName = sub.SubCategoryName; employeePortalEntities.SaveChanges(); retVal = true; } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } } return retVal; }
public String GetSubCategoryName(int id) { String retVal = ""; using (EcommerceEntities employeePortalEntities = new EcommerceEntities()) { try { var employeeEntity = (employeePortalEntities.SubCategories).Where(category => category.SubCategotyId == id).FirstOrDefault(); retVal = employeeEntity.SubCategoryName; } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } } return retVal; }
public bool isCategoryIdExist(int categoryId) { bool retVal = false; try { using (var database = new EcommerceEntities()) { Category category = database.Categories.Where(i => i.CategotyId == categoryId).FirstOrDefault(); if (category != null) { retVal = true; } } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } return retVal; }
public bool removeItem(int itemId) { bool retVal = false; try { using (var database = new EcommerceEntities()) { var itemEntities = database.Items; Item item = itemEntities.Where(i => i.ItemId == itemId).FirstOrDefault(); if (item != null) { itemEntities.Remove(item); database.SaveChanges(); retVal = true; } } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } return retVal; }
public bool removeCategory(int categoryId) { bool retVal = false; try { using (var database = new EcommerceEntities()) { var categoryEntities = database.Categories; Category category = categoryEntities.Where(i => i.CategotyId == categoryId).FirstOrDefault(); if (category != null) { categoryEntities.Remove(category); database.SaveChanges(); retVal = true; } } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } return retVal; }
public bool isSubCategoryNameUnique(int categotyId, String subCategoryName) { bool retVal = true; try { using (var database = new EcommerceEntities()) { SubCategory subCategory = database.SubCategories.Where(i => i.CategotyId == categotyId && i.SubCategoryName == subCategoryName).FirstOrDefault(); if (subCategory != null) { retVal = false; } } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } return retVal; }
public bool isItemNameUnique(String itemName, int subCategoryId) { bool retVal = true; try { using (var database = new EcommerceEntities()) { Item item = database.Items.Where(i => i.ItemName == itemName && i.SubCategotyId == subCategoryId).FirstOrDefault(); if (item != null) { retVal = false; } } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } return retVal; }
public IList<ICategoriesDTO> GetAllCategories() { IList<ICategoriesDTO> employeeDTOList = new List<ICategoriesDTO>(); ICategoriesDTO employeeDTO = null; using (EcommerceEntities employeePortalEntities = new EcommerceEntities()) { try { var employeeEntity = (employeePortalEntities.Categories); foreach (var emp in employeeEntity) { employeeDTO = (ICategoriesDTO)DTOFactory.Instance.Create(DTOType.Category); EntityConverter.FillDTOFromEntity(emp, employeeDTO); employeeDTOList.Add(employeeDTO); } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } } return employeeDTOList; }
public ISubCategoriesDTO getSubCategory(int employeeId) { ISubCategoriesDTO employeeDTO = null; using (EcommerceEntities employeePortalEntities = new EcommerceEntities()) { try { var employeeEntity = employeePortalEntities.SubCategories.FirstOrDefault(employee => employee.SubCategotyId == employeeId); if (employeeEntity != null) { employeeDTO = (ISubCategoriesDTO)DTOFactory.Instance.Create(DTOType.SubCategory); EntityConverter.FillDTOFromEntity(employeeEntity, employeeDTO); } } catch (Exception ex) { ExceptionManager.HandleException(ex); throw new DACException(ex.Message, ex); } } return employeeDTO; }