protected IEnumerable <CategoryView> GetCategories()
        {
            GetAllCategoriesResponse response =
                _service.GetAllCategories();

            return(response.Categories);
        }
Esempio n. 2
0
        public IEnumerable <CategoryView> GetCategories()
        {
            GetAllCategoriesResponse response =
                _productCatalogService.GetAllCategories();

            return(response.Categories);
        }
Esempio n. 3
0
        public GetAllCategoriesResponse GetAllCategories(GetAllCategoriesRequest Request)
        {
            var Response = new GetAllCategoriesResponse();

            try
            {
                Response.Categories = _unitOfWork.RepositoryFactory <Category>()
                                      .GetAll()
                                      .Select(
                    q => new CategoryDTO
                {
                    Id             = q.Id,
                    Name           = q.Name,
                    Category_Meals = q.Meals.Select(
                        w => new MealDTO
                    {
                        Id   = w.Id,
                        Name = w.Name
                    }).ToList()
                }).ToList();
                Response.SetBaseResponse(true, 0, "");
            }
            catch (Exception ex)
            {
                Response.SetBaseResponse(false, 0, ex.Message);
            }
            return(Response);
        }
        private async Task <GetAllCategoriesResponse> DisplayCategories()
        {
            GetAllCategoriesResponse getCategoryResponse = null;

            if (SaleItemGlobal.selectedCategories.Count == 0)
            {
                JsonValue GetCategoryResponse = await HttpRequestHelper <GetRecieptRequest> .ParameterLessGetRequest(ServiceTypes.GetAllCategories);

                getCategoryResponse = JsonConvert.DeserializeObject <GetAllCategoriesResponse>(GetCategoryResponse.ToString());
                if (getCategoryResponse.IsSuccess)
                {
                    ListCategories = new ObservableCollection <CategoryDTO>();
                    foreach (CategoryDTO category in getCategoryResponse.CategoryDtOs)
                    {
                        ListCategories.Add(category);
                    }
                }
                else
                {
                }
            }
            else
            {
                ListCategories = new ObservableCollection <CategoryDTO>();
                foreach (CategoryDTO category in SaleItemGlobal.selectedCategories)
                {
                    ListCategories.Add(category);
                }
            }
            return(getCategoryResponse);
        }
Esempio n. 5
0
        public GetAllCategoriesResponse GetAllCategories()
        {
            var response = new GetAllCategoriesResponse();

            response.Categories = _categoryRepository.FindAll().ToCategoryViews();

            return(response);
        }
        public GetAllCategoriesResponse GetAllCategories()
        {
            var response = new GetAllCategoriesResponse();

            response.Categories = _presentationRepository.FindByType <CategoryDto>();

            return(response);
        }
        public GetAllCategoriesResponse GetAllCategories()
        {
            GetAllCategoriesResponse response = new GetAllCategoriesResponse();

            response.Categories = _categoryRepository.FindAll().Select(c => _mapper.Map <Category, CategoryView>(c));

            return(response);
        }
        public override async Task <GetAllCategoriesResponse> GetAllCategories(GetAllCategoriesRequest request,
                                                                               ServerCallContext context)
        {
            var response      = new GetAllCategoriesResponse();
            var eventEntities = await _categoryRepository.GetAllCategories();

            response.Categories.Add(_mapper.Map <List <Category> >(eventEntities));
            return(response);
        }
        public GetAllCategoriesResponse GetAllCategories()
        {
            GetAllCategoriesResponse response   = new GetAllCategoriesResponse();
            IEnumerable <Category>   categories = _categoryRepository.FindAll();

            response.Categories = _mapper.Map <IEnumerable <CategoryView> >(categories);

            return(response);
        }
Esempio n. 10
0
        public GetAllCategoriesResponse GetAllCategories()
        {
            GetAllCategoriesResponse response   = new GetAllCategoriesResponse();
            IEnumerable <Category>   categories = _categoryRepository.FindAll();

            response.Categories = categories.ConvertToCategoryViews();

            return(response);
        }
Esempio n. 11
0
        public async Task GetAll_ShouldSuccess()
        {
            //ARRANGE
            const string catDesc     = "cat desc";
            const string catDesc2    = "cat desc2";
            const string catName     = "cat name";
            const string catName2    = "cat name2";
            var          categoryId  = new Guid("7BC0C011-7FA3-4AA4-B260-257465831D65");
            var          categoryId2 = new Guid("FB7871B2-B08F-487F-9739-0172C77A4BDD");


            var categories = new List <Category>
            {
                new Category
                {
                    Description = catDesc,
                    Name        = catName,
                    Id          = categoryId
                },
                new Category
                {
                    Description = catDesc,
                    Name        = catName,
                    Id          = categoryId
                }
            };


            _categoryRepositoryMock.Setup(cr => cr.GetAllCategories())
            .ReturnsAsync(categories);

            //ACT
            GetAllCategoriesResponse actual = await _categoryService.GetAll();

            //ASSERT
            var expected = new GetAllCategoriesResponse
            {
                Categories = new List <CategoryDto>
                {
                    new CategoryDto
                    {
                        Description = catDesc,
                        Name        = catName,
                        Id          = categoryId
                    },
                    new CategoryDto
                    {
                        Description = catDesc2,
                        Name        = catName2,
                        Id          = categoryId2
                    }
                }
            };

            ContentAssert.AreCollectionsEquivalent(expected.Categories, actual.Categories);
        }
Esempio n. 12
0
        GetAllCategories(GetAllCategoriesRequest request, ServerCallContext context)
        {
            var all = await _categoryRepository.FetchAllAsync(request.Count);

            var response = new GetAllCategoriesResponse();

            response.Categories.AddRange(all.Select(p => p.MapToMessage()));

            return(response);
        }
        public async Task <ActionResult <GetAllCategoriesResponse> > Update([FromRoute] int id, [FromBody] AddCategoryRequest request)
        {
            var oldcategory = _context.Categories
                              .FirstOrDefault(x => x.Id == request.Id);

            if (oldcategory == null)
            {
                return(NotFound());
            }

            oldcategory.Name        = request.Name;
            oldcategory.Description = request.Description;
            oldcategory.ParentId    = request.ParentId;
            oldcategory.Color       = request.Color;

            if (request.tags != null)
            {
                var categoryTags = new List <CategoryTag>();
                var oldTags      = _context.CategoryTags.Where(temp => temp.CategoryId == oldcategory.Id);
                foreach (var item in oldTags)
                {
                    _context.CategoryTags.Remove(item);
                }
                request.tags.ForEach(tag =>
                {
                    CategoryTag categoryTag = new CategoryTag();
                    categoryTag.CategoryId  = oldcategory.Id;
                    categoryTag.TagId       = _context.Tags.First(temp => temp.Name == tag).Id;
                    categoryTags.Add(categoryTag);
                    _context.CategoryTags.Add(categoryTag);
                });
                oldcategory.CategoryTags = categoryTags;
            }
            if (oldcategory.SchedulerEvents == null)
            {
                oldcategory.SchedulerEvents = new List <SchedulerEvent>();
            }
            var response = new GetAllCategoriesResponse();

            response.Id              = oldcategory.Id;
            response.Name            = oldcategory.Name;
            response.ParentId        = request.ParentId;
            response.SchedulerEvents = oldcategory.SchedulerEvents.ToList();
            response.Tags            = request.tags;
            response.Color           = oldcategory.Color;
            response.Description     = oldcategory.Description;

            await _context.SaveChangesAsync();

            return(Ok(response));
        }
        public GetAllCategoriesResponse GetAllCategories()
        {
            GetAllCategoriesResponse response = new GetAllCategoriesResponse();

            response.Catagories = repo.GetAllCategories();
            if (response.Catagories == null)
            {
                response.Success = false;
                response.Message = "No Catagories Found";
                return(response);
            }
            response.Success = true;
            response.Message = "Success";
            return(response);
        }
Esempio n. 15
0
        public GetAllCategoriesResponse GetAllCategories()
        {
            lock (_getAllCategoriesLock)
            {
                GetAllCategoriesResponse response =
                    _cachStorage.Retrieve <GetAllCategoriesResponse>(CacheKeys.AllCategories.ToString());

                if (response == null)
                {
                    response = _realProductCatalogueService.GetAllCategories();
                    _cachStorage.Store(CacheKeys.AllCategories.ToString(), response);
                }

                return(response);
            }
        }
        public async override Task <GetAllCategoriesResponse> GetAllCategories(Google.Protobuf.WellKnownTypes.Empty request, ServerCallContext context)
        {
            var result = await _mediator.Send(new Application.Categories.GetListRequest());

            var response = new GetAllCategoriesResponse
            {
                StatusCode   = 0,
                Message      = string.Empty,
                ResponseData = new GetAllCategoriesResponse.Types.ResponseData
                {
                    ListCategory =
                    {
                        result.Adapt <IEnumerable <CategoryResponse> >()
                    }
                }
            };

            return(response);
        }
        public async Task <GetAllCategoriesResponse> GetAllAsync(GetAllCategoriesRequest request)
        {
            return(await Task.Run(() =>
            {
                var response = new GetAllCategoriesResponse();

                try
                {
                    var allCategories = unitOfWork.CategoryRepository.GetAllCategories();
                    var mapper = mapperConfig.CreateMapper();

                    response.Categories = mapper.Map <IEnumerable <Category>, IEnumerable <CategoryViewModel> >(allCategories);
                }
                catch (Exception ex)
                {
                    response.Exception = ex;
                }

                return response;
            }));
        }
        public async Task <ActionResult <GetAllCategoriesResponse> > Add([FromBody] AddCategoryRequest request)
        {
            var newCategory = new Category()
            {
                Name        = request.Name,
                Description = request.Description,
                Color       = request.Color,
                ParentId    = request.ParentId,
            };

            newCategory.SchedulerEvents = new List <SchedulerEvent>();
            var categoryTags = new List <CategoryTag>();

            if (request.tags != null)
            {
                request.tags.ForEach(tag =>
                {
                    CategoryTag categoryTag = new CategoryTag();
                    categoryTag.CategoryId  = newCategory.Id;
                    categoryTag.TagId       = _context.Tags.First(temp => temp.Name == tag).Id;
                    categoryTags.Add(categoryTag);
                    _context.CategoryTags.Add(categoryTag);
                });
            }
            newCategory.CategoryTags = categoryTags;
            _context.Categories.Add(newCategory);
            await _context.SaveChangesAsync();

            var response = new GetAllCategoriesResponse();

            response.Id              = newCategory.Id;
            response.Name            = newCategory.Name;
            response.ParentId        = request.ParentId;
            response.SchedulerEvents = newCategory.SchedulerEvents.ToList();
            response.Tags            = request.tags;
            response.Color           = newCategory.Color;
            response.Description     = newCategory.Description;
            return(Ok(response));
        }
        protected IEnumerable <CategoryView> GetCategories()
        {
            GetAllCategoriesResponse response = _cachedProductCatalogService.GetAllCategories();

            return(response.Categories);
        }