public ActionResult <ShopListModel> UpdateShopList(int id, ShopListModel model)
        {
            try
            {
                if (model == null)
                {
                    return(BadRequest());
                }

                var result = _repository.GetShopListById(id);

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

                _mapper.Map(model, result);

                if (_repository.SaveChanges())
                {
                    return(_mapper.Map <ShopListModel>(result));
                }

                return(BadRequest("Failed to update ShopList in database"));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Something went wrong inside UpdateShopList Action: {ex}");
                return(StatusCode(StatusCodes.Status500InternalServerError, "Internal Server error"));
            }
        }
        public ActionResult <ShopListModel> AddShopList(ShopListModel model)
        {
            try
            {
                if (model == null)
                {
                    return(BadRequest());
                }

                var result = _mapper.Map <ShopList>(model);

                _repository.Add(result);

                if (_repository.SaveChanges())
                {
                    return(Created($"api/´shoplists/{model.ShopListId}", _mapper.Map <ShopListModel>(result)));
                }

                return(BadRequest("Failed to add ShopList in database"));
            }
            catch (Exception ex)
            {
                _logger.LogError($"Something went wrong inside AddShopList Action: {ex}");
                return(StatusCode(StatusCodes.Status500InternalServerError, "Internal Server error"));
            }
        }
Ejemplo n.º 3
0
        public ActionResult Index(ShopListFiltersModel filters)
        {
            int pageTotal;

            var shops = _shopService.GetShopByStatus("CreatedDate", "DESC", filters.CategoryId, filters.TownId, StatusEnum.Pending, filters.Criteria, filters.Page, DefaultPageSize, out pageTotal);

            var pagedList = new StaticPagedList <ShopDto>(shops, filters.Page, DefaultPageSize, pageTotal);

            var listModel = new ShopListModel(pagedList, filters);

            ViewBag.ViewMode = StatusEnum.Pending;
            ViewBag.TabTitle = "Comercios Pendientes";
            ViewBag.Title    = "Comercios Pendientes de Aprobación";

            return(View(listModel));
        }
Ejemplo n.º 4
0
        public ActionResult RejectedShop(ShopListFiltersModel filters)
        {
            int pageTotal;

            var shops = _shopService.GetShopByStatus("CreatedDate", "ASC", filters.CategoryId, filters.TownId, StatusEnum.Rejected, filters.Criteria, filters.Page, DefaultPageSize, out pageTotal);

            var pagedList = new StaticPagedList <ShopDto>(shops, filters.Page, DefaultPageSize, pageTotal);

            var listModel = new ShopListModel(pagedList, filters);

            ViewBag.ViewMode = StatusEnum.Rejected;
            ViewBag.TabTitle = "Comercios Rechazados";
            ViewBag.Title    = "Comercios Rechazados";

            return(View("Index", listModel));
        }
Ejemplo n.º 5
0
        public ActionResult List(string listFor = "all", int?catId = null, int page = 1, string keyword = "")
        {
            keyword = keyword.Trim();
            var catItem   = GetShopCats().SingleOrDefault(r => catId != null && r.Value == catId.Value.ToString());
            var viewModel = new ShopListModel
            {
                PagingShops = _shopService.GetPagedList(listFor, catId, keyword, page - 1, string.Empty, string.Empty, 24),  //_shopWithProductService.GetList(listFor, catId, page - 1, keyword, tag),
                Keyword     = keyword,
                ListFor     = listFor,
                CatName     = catItem == null ? "全部" : catItem.Text,
                CatId       = catId
            };

            ViewBag.Keyword = keyword;

            return(View(viewModel));
        }
Ejemplo n.º 6
0
        public ActionResult List(int pageSize = 15, int pageNumber = 1)
        {
            string condition = Shop.AdminGetShopListCondition("");
            string sort      = Shop.AdminGetShopListSort("", "");

            PageModel pageModel = new PageModel(pageSize, pageNumber, Shop.AdminGetShopCount(condition));

            ShopListModel model = new ShopListModel()
            {
                DataList  = Shop.AdminGetShopList(pageModel.PageSize, pageModel.PageNumber, condition, sort),
                PageModel = pageModel
            };

            SiteUtils.SetAdminRefererCookie(Url.Action("List", "Shop"));

            return(View(model));
        }
Ejemplo n.º 7
0
        public IActionResult ShopList(ShopListOptions options)
        {
            var repo = new EcomRepository();
            var cart = PageMaster.GetShoppingCart();

            int total;
            var model = new ShopListModel
            {
                ShopList = repo.GetShopList(options, cart, out total),
                Brands   = repo.GetAllBrands()
            };

            options.TotalItems = total;

            ViewBag.Options        = options;
            ViewBag.CountCartItems = cart.CartProducts != null?cart.CartProducts.Count() : 0;

            return(View(model));
        }
Ejemplo n.º 8
0
        public IActionResult ShopList(ShopListOptions options)
        {
            ShoppingCart cart;

            if (SignInManager.IsSignedIn(User))
            {
                string cartId = UserManager.GetUserId(User);
                cart = Repository.GetCartById(cartId);
            }
            else
            {
                try
                {
                    string requestCookie = HttpContext.Request.Cookies[_cartCookieName];
                    cart = JsonConvert.DeserializeObject <ShoppingCart>(requestCookie);
                }
                catch (Exception)
                {
                    cart = new ShoppingCart()
                    {
                        Id           = Guid.NewGuid().ToString(),
                        CartProducts = new List <CartProduct>()
                    };
                    HttpContext.Response.Cookies
                    .Append(_cartCookieName, JsonConvert.SerializeObject(cart));
                }
            }

            var model = new ShopListModel();
            int total;

            model.ShopList  = Repository.GetShopList(options, cart, out total);
            model.Brands    = Repository.GetAllBrands();
            model.TotalPage = total / (options.PageSize ?? 20);

            ViewBag.Options        = options;
            ViewBag.CountCartItems = cart.CartProducts.Count();
            return(View(model));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 门店列表
        /// </summary>
        /// <returns></returns>
        public ActionResult List()
        {
            int classid = GetRouteInt("classid");

            if (classid == 0)
            {
                classid = WebHelper.GetQueryInt("classid");
            }

            string area = GetRouteString("area");

            if (area == "")
            {
                area = WebHelper.GetQueryString("area");
            }
            if (area == "")
            {
                area = "全部";
            }


            int page = GetRouteInt("page");

            if (page == 0)
            {
                page = WebHelper.GetQueryInt("page");
            }


            ArticleClassInfo info = ArticleClass.GetModelById(classid);

            if (info == null)
            {
                return(PromptView("/", "您访问的页面不存在"));
            }


            string condition = Shop.GetShopListCondition(area, "全部", "");
            string sort      = Shop.GetShopListSort("", "asc");

            PageModel pageModel = new PageModel(20, page, Shop.GetShopCount(condition));



            ShopListModel model = new ShopListModel
            {
                ArticleClassID   = classid,
                ArticleClassInfo = info,
                ClassPath        = ArticleClass.GetArticleClassPath(classid),
                Area             = area,
                ShopList         = Shop.GetShopList(pageModel.PageSize, pageModel.PageNumber, condition, sort),
                PageModel        = pageModel
            };

            //if (info.ListView.Length > 0)
            //    return View("List." + info.ListView, model);
            //else
            //    return View(model);


            List <SelectListItem> shopareaList = new List <SelectListItem>();

            shopareaList.Add(new SelectListItem()
            {
                Text  = "全部",
                Value = ""
            });
            foreach (DataRow drRow in Shop.GetShopAreaList().Rows)
            {
                shopareaList.Add(new SelectListItem()
                {
                    Text  = drRow["area"].ToString(),
                    Value = drRow["area"].ToString()
                });
            }

            ViewData["shopareaList"] = shopareaList;

            return(View(model));
        }