Ejemplo n.º 1
0
 //Manage Category//
 // GET: Admin/ManageCard
 public IActionResult ManageCategory()
 {
     if (IsAdmin())
     {
         var categories = _categoryServices.GetCategories();
         return(View(categories));
     }
     Alert("You not permit to access that page", NotificationType.warning);
     return(RedirectToAction("Login", "Home"));
 }
Ejemplo n.º 2
0
        private void LoadData()
        {
            try
            {
                dtPickerIssuedDate.MaxDate = new DateTime(DateTime.Now.Year, 12, 31);

                dtPickerFrom.MinDate = new DateTime(DateTime.Now.Year, 1, 1);
                dtPickerFrom.MaxDate = new DateTime(DateTime.Now.Year, 12, 31);
                dtPickerFrom.Value   = DateTime.Now;

                dtPickerTo.MinDate = dtPickerIssuedDate.Value.AddDays(1);
                dtPickerTo.Value   = dtPickerIssuedDate.Value.AddDays(2);

                var categoryList = _categoryServices.GetCategories().ToList();

                cbxCategory.DataSource    = categoryList;
                cbxCategory.DisplayMember = "Name";
                cbxCategory.ValueMember   = "Id";

                cbxCategorySearch.DataSource    = _categoryServices.GetCategories().ToList();
                cbxCategorySearch.DisplayMember = "Name";
                cbxCategorySearch.ValueMember   = "Id";

                var supplierList = _supplierServices.GetSuppliers().ToList();

                cbxSupplier.DataSource    = supplierList;
                cbxSupplier.DisplayMember = "CompanyName";
                cbxSupplier.ValueMember   = "Id";

                cbxSupplierSearch.DataSource    = supplierList;
                cbxSupplierSearch.DisplayMember = "CompanyName";
                cbxSupplierSearch.ValueMember   = "Id";

                cbxStatus.DataSource =
                    Enum.GetValues(typeof(ProductStatus)).Cast <Enum>().Select(value => new
                {
                    (Attribute.GetCustomAttribute(value.GetType().GetField(value.ToString()),
                                                  typeof(DescriptionAttribute)) as DescriptionAttribute).Description,
                    value
                })
                    .OrderBy(item => item.value)
                    .ToList();

                cbxStatus.DisplayMember = "Description";
                cbxStatus.ValueMember   = "value";
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                ErrorMessage();
                Close();
            }
        }
Ejemplo n.º 3
0
        public void AfterRegistration(string userID, string notificationDescription = null, IEnumerable <string> SelectedUserCategories = null)
        {
            try
            {
                var freeToken = _dbContext.Campain.FirstOrDefault(i => i.SlugUrl == "ilk-uyelik");
                if (freeToken != null)
                {
                    var bought = new BoughtHistory()
                    {
                        Id          = Guid.NewGuid(),
                        UserId      = userID,
                        CampainId   = freeToken.Id,
                        CreatedDate = DateTime.Now,
                        IsPaid      = true
                    };
                    _dbContext.BoughtHistory.Add(bought);

                    if (!string.IsNullOrEmpty(notificationDescription))
                    {
                        _notificationService.AddNotification(userID, NotificationTypes.RegistrationExternalProvider, param: notificationDescription);
                    }
                    else
                    {
                        _notificationService.AddNotification(userID, NotificationTypes.Registration);
                    }
                }

                if (SelectedUserCategories != null && SelectedUserCategories.Count() > 0)
                {
                    var categories = _categoryServices.GetCategories();
                    foreach (var relation in SelectedUserCategories)
                    {
                        var category = categories.FirstOrDefault(i => i.SlugUrl == relation);

                        if (category != null)
                        {
                            _dbContext.UserCategoryRelation.Add(new UserCategoryRelation()
                            {
                                Id         = Guid.NewGuid(),
                                CategoryId = category.Id,
                                SelectDate = DateTime.Now,
                                UserId     = userID
                            });
                        }
                    }
                }

                _dbContext.SaveChanges();
            }
            catch { }
        }
        private async Task <IEnumerable <TransactionViewModel> > GetTransactionsViewModel(IEnumerable <Transaction> transactions)
        {
            var filePath   = Tools.Directory.DirectoryTools.GetCategoryCsvFilePath(_configuration);
            var categories = await _categoryServices.GetCategories(filePath);

            var categoriesOrderedByName  = categories.OrderBy(c => c.Name);
            var transactionViewModels    = _mapper.MapToTransactionViewModels(transactions);
            var transactionViewModelList = transactionViewModels.ToList();

            foreach (var transaction in transactionViewModelList)
            {
                transaction.Categories = categoriesOrderedByName;
            }
            return(transactionViewModelList);
        }
Ejemplo n.º 5
0
 //IEnumerable<Page> pages
 async public Task <IViewComponentResult> InvokeAsync()
 {
     return(View(new CategoriesComponentViewModel()
     {
         Categories = _categoryServices.GetCategories()
     }));
 }
        private async Task <IEnumerable <Category> > GetCategories()
        {
            var filePath   = Tools.Directory.DirectoryTools.GetCategoryCsvFilePath(_configuration);
            var categories = await _categoryServices.GetCategories(filePath);

            return(categories);
        }
Ejemplo n.º 7
0
        private void LoadData()
        {
            dtPickerIssuedDate.MinDate = new DateTime(DateTime.Now.Year, 1, 1);
            dtPickerIssuedDate.MaxDate = new DateTime(DateTime.Now.Year, 12, 31);
            dtPickerIssuedDate.Value   = DateTime.Now;

            dtPickerExpiredDate.MinDate = dtPickerIssuedDate.Value.AddDays(1);
            dtPickerExpiredDate.Value   = dtPickerIssuedDate.Value.AddDays(2);

            var categoryList = _categoryServices.GetCategories().ToList();

            cbxCategory.DataSource    = categoryList;
            cbxCategory.DisplayMember = "Name";
            cbxCategory.ValueMember   = "Id";
            cbxCategory.DropDownStyle = ComboBoxStyle.DropDownList;

            var supplierList = _supplierServices.GetSuppliers().ToList();

            cbxSupplier.DataSource    = supplierList;
            cbxSupplier.DisplayMember = "CompanyName";
            cbxSupplier.ValueMember   = "Id";

            cbxStatus.DataSource = Enum.GetValues(typeof(ProductStatus)).Cast <Enum>()
                                   .Select(value => new
            {
                (Attribute.GetCustomAttribute(value.GetType().GetField(value.ToString()), typeof(DescriptionAttribute)) as DescriptionAttribute).Description,
                value
            })
                                   .OrderBy(item => item.value).ToList();

            cbxStatus.DisplayMember = "Description";
            cbxStatus.ValueMember   = "value";
        }
 public IActionResult Index()
 {
     return(View(new CategoriesViewModel()
     {
         Categories = _categoryServices.GetCategories().Where(i => !i.ParentId.HasValue)
     }));
 }
Ejemplo n.º 9
0
        public CategoryValidator(ResourcesServices _resourcesServices, ICategoryServices _categoryServices)
        {
            var categories = _categoryServices.GetCategories();

            foreach (var category in categories)
            {
                RuleFor(x => x.CategoryName).NotEqual(category.CategoryName).WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_alreadyexists"));
            }
            RuleFor(x => x.CategoryName).NotNull().WithMessage(_resourcesServices.GetLocalizedHtmlString("vld_notnull"));
        }
Ejemplo n.º 10
0
        public IActionResult Index()
        {
            var model = new IndexViewModel()
            {
                categoryViewModels = categoryServices.GetCategories(),
                PageTitle          = "دسته بندی ها "
            };

            return(View(model));
        }
Ejemplo n.º 11
0
        private void LoadData()
        {
            var result = _categoryServices.GetCategories();

            if (result.Any())
            {
                _categoryList = result.Select(Mapper.Map <CategoryViewModel>).OrderBy(c => c.Code).ToList();
            }
            categoryViewModelBindingSource.DataSource = _categoryList;
        }
        public async Task <IActionResult> GetCategoryItems()
        {
            var category = await _services.GetCategories();

            if (category.Count == 0)
            {
                _logger.LogInformation("Category Not Found");
                return(NotFound());
            }

            return(Ok(category));
        }
        public async Task ShouldHaveListOfCategory()
        {
            // Arrange
            var faker    = new Faker();
            var filePath = faker.Random.String2(2);

            // Act
            var categories = await _categoryServices.GetCategories(filePath);

            // Assert
            Assert.True(categories.Any());
        }
Ejemplo n.º 14
0
        //DONE
        public ActionResult GetCategories()
        {
            try
            {
                var categories = _categoryServices.GetCategories();

                var categoriesToReturn = _mapper.Map <IEnumerable <CategoryVM> >(categories);

                return(PartialView("_ListOfCategories", categoriesToReturn));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Las categorías no pudieron ser cargadas."));
            }
        }
Ejemplo n.º 15
0
        public IActionResult Index()
        {
            var lastPorducts = _productServices.GetProducts().OrderByDescending(p => p.CreationDate).Take(5);

            var lastPorductsToReturn = _mapper.Map <IEnumerable <ProductVM> >(lastPorducts);

            var dashBoard = new DashboardVM
            {
                TotalOfPorducts   = _productServices.GetProducts().Count(),
                TotalOfCategries  = _categoryServices.GetCategories().Count(),
                TotalOfBrands     = _brandServices.GetBrands().Count(),
                TotalOfClients    = _clientServices.GetClients().Count(),
                LastAddedProducts = lastPorductsToReturn.ToList()
            };

            return(View(dashBoard));
        }
Ejemplo n.º 16
0
        public IActionResult Index(string keyword)
        {
            if (!string.IsNullOrWhiteSpace(keyword))
            {
                var possibleCategories = keyword.Split(' ');

                foreach (var item in possibleCategories)
                {
                    var category = _categoryServices.GetCategories().FirstOrDefault(i => i.Name.ToLowerInvariant().Split(' ').Contains(item.ToLowerInvariant()));

                    if (category != null)
                    {
                        return(RedirectToRoute("createItem", new { categoryslug = category.SlugUrl, title = keyword }));
                    }
                }
            }

            return(RedirectToRoute("createItem", new { title = keyword }));
        }
Ejemplo n.º 17
0
        private async Task <CreatePostViewModel> ConfigureCreatePostViewModel(ICategoryServices categoryServices, Post post, string creator)
        {
            CreatePostViewModel createPostViewModel = new CreatePostViewModel();

            if (creator != null)
            {
                post.PublishedBy = creator;
            }
            else
            {
                foreach (PostCategory postCategory in post.PostCategories)
                {
                    createPostViewModel.SelectedCategories.Add(postCategory.Category.Name);
                }
            }
            createPostViewModel.Post = post;

            List <Category> categories = await categoryServices.GetCategories();

            createPostViewModel.PopulateCategories(categories);
            return(createPostViewModel);
        }
Ejemplo n.º 18
0
        public IEnumerable <SelectListItem> GetUserCategories(bool addEmpty = false)
        {
            var result = _categoryServices.GetCategories()
                         .Select(i => i.Parent != null ? new SelectListItem()
            {
                Value = i.SlugUrl, Text = i.Parent.Name + " ˃ " + i.Name
            } : new SelectListItem()
            {
                Value = i.SlugUrl, Text = i.Name
            })
                         .OrderBy(i => i.Text)
                         .ToList();

            if (addEmpty)
            {
                result.Insert(0, new SelectListItem()
                {
                    Value = "", Text = "Kategori seçiniz..."
                });                                                                                  //, Text = "Kategori seçiniz..." });
            }
            return(result);
        }
Ejemplo n.º 19
0
        public ActionResult Index()
        {
            List <Category> list = _categoryServices.GetCategories();

            return(View());
        }
Ejemplo n.º 20
0
 // GET: Categories
 public async Task <IActionResult> Index()
 {
     return(View(await categoryServices.GetCategories()));
 }
Ejemplo n.º 21
0
        public async Task <List <CategoryResponseModel> > GetCategories()
        {
            var res = await _categoryServices.GetCategories();

            return(res.ToList());
        }
Ejemplo n.º 22
0
        //[Authorize(Roles = "User")]
        public async Task <BaseResponse <IList <Category> > > getCategories()
        {
            IList <Category> categories = await _categoryServices.GetCategories();

            return(new BaseResponse <IList <Category> >(categories));
        }
Ejemplo n.º 23
0
 public List <Category> Get()
 {
     return(_categoryServices.GetCategories());
 }
Ejemplo n.º 24
0
 public IActionResult GetCategory()
 {
     return(Ok(_categorysServices.GetCategories()));
 }
Ejemplo n.º 25
0
        private List <CategoryVM> GetCategories()
        {
            var categories = _mapper.Map <IEnumerable <CategoryVM> >(_categoryServices.GetCategories());

            return(categories.ToList());
        }
Ejemplo n.º 26
0
        public ActionResult Create()
        {
            ViewBag.CategoryId = new SelectList(_categoryServices.GetCategories(), "CategoryId", "Name");

            return(View());
        }