예제 #1
0
        //
        // GET: /Comm/

        public JsonResult GetTypeDescription(string cat)
        {
            var culture = GetCulture();
            var items   = _catalogService.Get(cat);
            var result  = items.Select(i => new
            {
                Id    = i.SubCategoryId + "",
                Value = culture == CatalogDescriptionLang.ES ? i.DescriptionES : i.DescriptionEN,
            });

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
        public Either <string, Catalog> Get()
        {
            var result = catalog.Get();

            result.IfLeft(_ => logger.Log(_));
            return(result);
        }
예제 #3
0
        public async Task <IActionResult> AddItemToCart(ItemCartDTO itemCart)
        {
            var product = await _catalogService.Get(itemCart.IdProduct);

            await ValidateItemCart(product, itemCart.Quantity);

            if (!OperacaoValida())
            {
                return(CustomResponse());
            }

            itemCart.Name  = product.Name;
            itemCart.Price = product.Price;
            itemCart.Image = product.Image;

            var response = await _cartService.AddItem(itemCart);

            return(CustomResponse(response));
        }
예제 #4
0
        public IActionResult CatalogEditor(int catalogId)
        {
            var catalog = catalogId > 0 ? _catalogService.Get(catalogId) : new Catalog();

            if (catalog == null)
            {
                return(NotFound());
            }
            var catalogModel    = _catalogModelFactory.Create(catalog);
            var stores          = _storeService.Get(x => true).ToList();
            var catalogStoreIds = catalog.Stores?.Select(x => x.Id).ToList() ?? new List <int>();
            var availableStores = SelectListHelper.GetSelectItemList(stores, x => x.Id, x => x.Name)
                                  .Select(x =>
            {
                if (catalogStoreIds.Any(y => y.ToString() == x.Value))
                {
                    x.Selected = true;
                }
                return(x);
            }).ToList();

            return(R.Success.With("catalog", catalogModel).With("availableStores", availableStores).Result);
        }
예제 #5
0
 public IActionResult Get(int id)
 {
     try
     {
         var catalog = _catalogService.Get(id);
         if (catalog == null)
         {
             return(null);
         }
         return(Ok(catalog.ToApiModel()));
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("GetCatalog", ex.Message);
         return(BadRequest(ModelState));
     }
 }
예제 #6
0
        public ActionResult Index(int?page, int?CatalogId)
        {
            int pageSize   = 3;
            int pageNumber = page ?? 1;

            ViewBag.Catalogs = _mapper.Map <IEnumerable <CatalogModel> >(_catalogService.Get());

            IEnumerable <ProductModel> products;

            if (CatalogId == null)
            {
                products = _mapper.Map <IEnumerable <ProductModel> >(_service.Get());
            }
            else
            {
                products = _mapper.Map <IEnumerable <ProductModel> >(_service.Get().Where(prod => prod.CatalogId == CatalogId.Value));
            }
            return(View(products.ToPagedList(pageNumber, pageSize)));
        }
 public Either <string, Catalog> Get()
 {
     return
         (Try(
              () => cache.Get()
              .Match(
                  _ => _,
                  () => catalog.Get()
                  .Match(
                      _ =>
     {
         cache.Set(_);
         return _;
     },
                      _ => (Either <string, Catalog>)_
                      )
                  )
              )
          .Match(
              _ => (Either <string, Catalog>)_,
              ex => (Either <string, Catalog>)ex.Message
              ));
 }
예제 #8
0
 public Dto.Product Get(string id)
 {
     return(catalogService.Get(id));
 }
예제 #9
0
        public IHttpActionResult Get(int id)
        {
            var catalog = _catalogService.Get(id);

            return(Ok(catalog));
        }
예제 #10
0
        // GET: Catalog
        public ActionResult Index()
        {
            IEnumerable <CatalogModel> catalogs = _mapper.Map <IEnumerable <CatalogModel> >(_service.Get());

            return(View(catalogs));
        }
예제 #11
0
        public async Task <IActionResult> Index()
        {
            var products = await _service.Get();

            return(View(products));
        }