public HttpResponseMessage GetProductsByCategoryKey(string id) { var allCategories = _category.All(); var category = allCategories.FirstOrDefault(z => z.PublicKey == id); if (category == null) { return(ErrorResult("no category")); } var products = _product.FindAll(z => z.CategoryId == category.Id); return(products.Count != 0 ? SuccessResult(products) : ErrorResult("no products")); }
public MainForm() { InitializeComponent(); _categoryRepository = new CategoryRepository(); _userRepository = new UserRepository(); _interfaceHelper = new InterfaceHelper(); var categories = _categoryRepository.All().Include(x => x.Books).ToList(); var users = _userRepository.All().ToList(); _interfaceHelper.FillTreeViewWithCategories(categoryTreeView, categories); _interfaceHelper.FillListViewWithCustomers(usersListView, users); }
public List <TicketListItem> GetExtendedTickes(List <Ticket> tickets) { var listOfTickets = (from t in tickets join p in ProjectRepository.All() on t.ProjectId equals p.ProjectId join c in CategoryRepository.All() on t.CategoryId equals c.CategoryId join pp in PriorityRepository.All() on t.PriorityId equals pp.PriorityId join aa in AreaRepository.All() on t.AreaId equals aa.AreaId join u in UserRepository.All() on t.OwnerUserId equals u.Id join uu in UserRepository.All() on t.AssignedTo equals uu.Id join st in StatusRepository.All() on t.TicketStatusId equals st.TicketStatusId select new TicketListItem { TicketDetailId = t.TicketDetailId, TicketNumber = t.TicketNumber.Value, ProjectId = p.ProjectId, ProjectName = p.ProjectName, CategoryId = c.CategoryId, Category = c.Name, PriorityId = pp.PriorityId, Priority = pp.Name, AreaId = aa.AreaId, AreaName = aa.Name, Title = t.Title, UserId = t.AssignedTo, AssignedUserName = uu.UserName, OwnerUserId = t.OwnerUserId, OwnerUserName = u.UserName, LastUpdateDate = t.LastUpdateDate.Value, Content = t.Details, IsLastDetail = t.IsLastDetail, IsBillable = t.IsBillable, StatusDescription = st.Name, CreatedDate = t.CreatedDate.Value, StatusId = st.TicketStatusId, Files = new List <FileData>() }).ToList(); foreach (var ticketListItem in listOfTickets) { ticketListItem.Files = FileDataRepository.Where(f => f.TicketDetailId == ticketListItem.TicketDetailId).ToList(); } return(listOfTickets); }
/// <summary> /// Descripcion del metodo GetCategoryList /// </summary> /// <returns></returns> public List <Category> GetCategoryList() { return(db.All()); }
public HttpResponseMessage GetAllCategories() { return(SuccessResult(_category.All())); }
public JSONFormat <List <ProductViewModel> > GetAllProducts() { JSONFormat <List <ProductViewModel> > result = null; //create productViewModel List to return for client List <ProductViewModel> productList = new List <ProductViewModel>(); try { //get all cateogories var categories = categoryRepository.All().Where(c => c.Active == true).ToList(); for (int i = 0; i < categories.Count; i++) { int cateID = categories[i].ID; //get all products of category var products = productRepository.GetAllProducts() .Where(q => q.CategoryID == cateID) .Where(q => q.Active == true).ToList(); if (products != null) { for (int j = 0; j < products.Count; j++) { //get product skus by productID int proID = products[j].ID; var productSkus = productSkuRepository.All() .Where(p => p.ProductID == proID) .Where(p => p.Active == true).ToList(); var proImageList = imageRepository.All(). Where(p => p.ProductID == proID).ToList(); List <string> imageList = new List <string>(); foreach (ProductImage item in proImageList) { imageList.Add(item.PicURL.ToString()); } if (productSkus != null) { //add products sku to product sku model List <ProductSkuViewModel> proSkus = new List <ProductSkuViewModel>(); foreach (ProductSku sku in productSkus) { //add productSkuViewModel to a product proSkus.Add(new ProductSkuViewModel() { ID = sku.ID, ProductID = sku.ProductID, Size = sku.Size, UnitPrice = sku.UnitPrice }); }//end for productSku productList.Add(new ProductViewModel() { ID = products[j].ID, Name = products[j].Name, Description = products[j].Description, imageList = imageList, ProductSkus = proSkus }); } //end if productSkus } //end for product } } result = new JSONFormat <List <ProductViewModel> > { status = new Status { success = true, message = ConstantManager.MES_GET_PRODUCT_SUCCESS, status = ConstantManager.STATUS_SUCCESS }, data = productList }; return(result); } catch (Exception ex) { result = new JSONFormat <List <ProductViewModel> > { status = new Status { success = false, message = ex.Message, status = ConstantManager.STT_FAIL }, data = null }; } return(result); }
public WidgetViewModel(PostRepository postRepository, TagRepository tagRepository, CategoryRepository categoryRepository) { Categories = categoryRepository.All().ToList(); Tags = tagRepository.All().ToList(); LatestPosts = postRepository.All().ToList(); }
public List <Category> GetCategories() { return(CategoryRepository.All().ToList()); }
public static List <Category> GetCategoryList() { var cdal = new CategoryRepository(); return(cdal.All()); }