Ejemplo n.º 1
0
        public async Task <IActionResult> ProductEdit(int id)
        {
            ViewData["Brands"] = _brandService.GetAll().Result.Select(

                n => new SelectListItem
            {
                Value = n.Id.ToString(),
                Text  = n.BrandName
            });
            ViewData["MainCategory"] = _maincategoryService.GetAll().Result.Select(

                n => new SelectListItem
            {
                Value = n.Id.ToString(),
                Text  = n.CategoyName
            });
            ViewData["SubCategory"] = _subcategoryService.GetAll().Result.Select(

                n => new SelectListItem
            {
                Value = n.Id.ToString(),
                Text  = n.CategoyName
            });
            return(View(await _productService.GetById(id)));
        }
Ejemplo n.º 2
0
        public IActionResult Update(int productId, int subCategoryId)
        {
            ProductUpdateViewModel model = new ProductUpdateViewModel()
            {
                Product       = _productService.GetByProductId(productId),
                Categories    = _categoryService.GetAllCategories(),
                SubCategories = _subCategoryService.GetAll(),
            };

            return(View(model));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create()
        {
            var subCategoryList = await _subCategoryService.GetAll();

            ViewBag.subCategoryDDL = subCategoryList.Result.Select(x => new SelectListItem
            {
                Selected = false,
                Text     = x.SubCategoryName,
                Value    = x.Id.ToString()
            }).ToList();
            return(View());
        }
        // GET: StudyMaterials
        public ActionResult Index()
        {
            var subcategorylist = _subCategoryService.GetAll();

            ViewBag.subcategory = new SelectList(subcategorylist.Where(i => i.Status == true), "Id", "Name", selectedValue: "Id");
            return(View());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get Shop By Master Category
        /// </summary>
        /// <param name="masterCategory"></param>
        /// <returns>Returns All shops which linked with the provided master category</returns>
        public IEnumerable <Shop> ByMasterCategory(string masterCategory)
        {
            List <Shop> shops = null;

            // Get all Sub Categories
            var allSubCategory = _subCategoryService.GetAll();

            if (allSubCategory.IsNotNullOrEmpty())
            {
                // Filter out all Sub category corresponding to the master category
                var subcategoryCorrespondingToMaster = allSubCategory.Where(x => x.MasterCategory?.Clean() == masterCategory?.Clean());
                if (subcategoryCorrespondingToMaster.IsNotNullOrEmpty())
                {
                    // Get products which is selected to the filtered sub category
                    foreach (var subCategory in subcategoryCorrespondingToMaster)
                    {
                        var filteredShops = BySubCategory(subCategory.Name);

                        if (filteredShops.IsNotNullOrEmpty())
                        {
                            if (shops == null)
                            {
                                shops = new List <Shop>();
                            }

                            shops.AddRange(filteredShops);
                        }
                    }
                }
            }
            // Show distinct Result
            return(shops?.DistinctBy(x => x.Id));
        }
Ejemplo n.º 6
0
        public ActionResult <IEnumerable <SubCategoryDto> > GetAll()
        {
            var subCategories = _subCategoryService.GetAll();

            if (subCategories == null)
            {
                List <string> errorMessage = new List <string>();
                errorMessage.Add("Đã phát sinh lỗi, vui lòng thử lại");
                return(BadRequest(new ResponseDto(errorMessage, 500, subCategories)));
            }
            List <string> successMessage = new List <string>();

            successMessage.Add("Lấy danh mục con hàng hoá thành công");
            var responseDto = new ResponseDto(successMessage, 200, subCategories);

            return(Ok(responseDto));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> GetAll([FromQuery] UserParamsModel userParams)
        {
            var categories = await _service.GetAll(userParams);

            Response.AddPaginationHeader(categories.CurrentPage, userParams.PageSize, categories.TotalItems, categories.TotalPage);

            return(Ok(categories));
        }
Ejemplo n.º 8
0
        public IActionResult GetAll()
        {
            var entity = _manager.GetAll();

            if (entity.Count == 0)
            {
                return(NoResult());
            }
            return(ResponseJson(entity));
        }
Ejemplo n.º 9
0
        public ViewViewComponentResult Invoke()
        {
            CategoryListViewModel model = new CategoryListViewModel()
            {
                Categories    = _categoryService.GetAllCategories(),
                SubCategories = _subCategoryService.GetAll(),
            };

            return(View(model));
        }
 public IActionResult Get()
 {
     try
     {
         return(Ok(_subCategoryService.GetAll()));
     }
     catch (Exception ex)
     {
         return(BadRequest("Subcategory not found"));
     }
 }
 public IActionResult GetAllSubCategories(int categoryId)
 {
     try
     {
         var subcategories = _subCategoryService.GetAll(categoryId);
         return(Ok(subcategories));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Ejemplo n.º 12
0
        public ViewViewComponentResult Invoke()
        {
            CategoryListViewModel model = new CategoryListViewModel()
            {
                Categories         = _categoryService.GetAllCategories(),
                SubCategories      = _subCategoryService.GetAll(),
                CurrentCategory    = Convert.ToInt32(HttpContext.Request.Query["category"]),
                CurrentSubCategory = Convert.ToInt32(HttpContext.Request.Query["subCategory"]),
                CurrentAction      = HttpContext.Request.Path,
            };

            return(View(model));
        }
        public IEnumerable <SubCategory> GetAll()
        {
            try
            {
                var categories = _subCategoryService.GetAll();

                return(categories);
            }
            catch (Exception ex)
            {
                _logger.Error <MasterCategoryController>(ex, "Error Occured while getting all sub categories.");
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Ejemplo n.º 14
0
        public IActionResult Index()
        {
            var product = _productService.GetAllProducts();
            ProductListViewModel model = new ProductListViewModel()
            {
                Products      = product,
                Categories    = _categoryService.GetAllCategories(),
                SubCategories = _subCategoryService.GetAll(),
                GetWines      = _productService.GetByCategoryId(1),
                CurrentAction = HttpContext.Request.ContentType,
                GetBeers      = _productService.GetByCategoryId(2),
            };

            return(View(model));
        }
Ejemplo n.º 15
0
        public async Task <IActionResult> GetAll()
        {
            Response oR = new Response();

            try
            {
                var lst = await _service.GetAll();

                oR.Status = StatusCodes.Status200OK;
                oR.Data   = lst;

                return(Ok(oR));
            }
            catch (Exception ex)
            {
                oR.Status  = StatusCodes.Status500InternalServerError;
                oR.Message = Messages.InternalServerError;

                return(StatusCode(StatusCodes.Status500InternalServerError, oR));
            }
        }
Ejemplo n.º 16
0
        public async Task <ActionResult> Create(ExamResource examresource)
        {
            if (ModelState.IsValid)
            {
                var exam = Mapper.Map <ExamResource, Exam>(examresource);
                exam.CreatedDate = DateTime.Now;
                exam.UpdatedDate = DateTime.Now;
                var userId = System.Web.HttpContext.Current.User.Identity.GetUserId();
                exam.UserId = userId;

                await _examservice.AddAsync(exam);

                _examservice.UnitOfWorkSaveChanges();

                return(RedirectToAction("Index"));
            }
            var examtype    = _examTypeService.GetAll();
            var subcategory = _subCategoryService.GetAll();

            ViewBag.ExamtypeId    = new SelectList(examtype.Where(i => i.Status == true), "Id", "Name", examresource.Examtypeid);
            ViewBag.SubcategoryId = new SelectList(subcategory.Where(i => i.Status == true), "Id", "Name", examresource.SubcategoryId);
            return(View(examresource));
        }
Ejemplo n.º 17
0
        public async Task <AddCardCommand> MapToAddCommand(YugiohCard yugiohCard)
        {
            ICollection <Category> categories = await _categoryService.GetAll();

            ICollection <SubCategory> subCategories = await _subCategoryService.GetAll();

            var command = new AddCardCommand();

            command.CardType    = yugiohCard.CardType;
            command.CardNumber  = yugiohCard.CardNumber;
            command.Name        = yugiohCard.Name;
            command.Description = yugiohCard.Description;

            if (yugiohCard.ImageUrl != null)
            {
                command.ImageUrl = new Uri(yugiohCard.ImageUrl);
            }


            if (command.CardType.Equals(YgoCardType.Spell.ToString(), StringComparison.OrdinalIgnoreCase))
            {
                command.SubCategoryIds = new List <int>
                {
                    SubCategoryId(categories, subCategories, YgoCardType.Spell, yugiohCard.Property)
                };
            }
            else if (command.CardType.Equals(YgoCardType.Trap.ToString(), StringComparison.OrdinalIgnoreCase))
            {
                command.SubCategoryIds = new List <int>
                {
                    SubCategoryId(categories, subCategories, YgoCardType.Trap, yugiohCard.Property)
                };
            }
            else
            {
                ICollection <Type> types = await _typeService.GetAll();

                ICollection <Attribute> attributes = await _attributeService.GetAll();

                ICollection <LinkArrow> linkArrows = await _linkArrowService.GetAll();

                var monsterCategory      = categories.Single(c => c.Name.Equals(YgoCardType.Monster.ToString(), StringComparison.OrdinalIgnoreCase));
                var monsterSubCategories = subCategories.Select(sc => sc).Where(sc => sc.CategoryId == monsterCategory.Id);

                command.AttributeId = MonsterAttributeId(yugiohCard, attributes);

                command.SubCategoryIds = MonsterSubCategoryIds(yugiohCard, monsterSubCategories);
                command.TypeIds        = MonsterTypeIds(yugiohCard, types);

                if (yugiohCard.LinkArrows != null)
                {
                    command.LinkArrowIds = MonsterLinkArrowIds(yugiohCard, linkArrows);
                }


                if (yugiohCard.Level.HasValue)
                {
                    command.CardLevel = yugiohCard.Level;
                }

                if (yugiohCard.Rank.HasValue)
                {
                    command.CardRank = yugiohCard.Rank;
                }

                if (!string.IsNullOrWhiteSpace(yugiohCard.AtkDef))
                {
                    var atk = Atk(yugiohCard);
                    var def = DefOrLink(yugiohCard);

                    int.TryParse(atk, out var cardAtk);
                    int.TryParse(def, out var cardDef);

                    command.Atk = cardAtk;
                    command.Def = cardDef;
                }

                if (!string.IsNullOrWhiteSpace(yugiohCard.AtkLink))
                {
                    var atk = Atk(yugiohCard);

                    int.TryParse(atk, out var cardAtk);

                    command.Atk = cardAtk;
                }
            }

            return(command);
        }
Ejemplo n.º 18
0
 public IActionResult Get()
 {
     return(Ok(_subCategoryService.GetAll()));
 }
        public async Task <IActionResult> Index()
        {
            var getAllService = await _subCategoryService.GetAll();

            return(View(getAllService.Result));
        }
        //POST: SubCategory

        public JsonResult SubCategory(int categoryId)
        {
            var subcategorylist = _subCategoryService.GetAll().Where(i => i.CategoryId == categoryId).ToList();

            return(Json(subcategorylist));
        }
Ejemplo n.º 21
0
        public async Task <ActionResult> Get()
        {
            var entities = await _service.GetAll();

            return(Ok(entities));
        }