예제 #1
0
        public ActionResult LoadProductByStore(string StoreId)
        {
            var model = new InteProductViewModels();

            try
            {
                var result = _factory.GetListProduct((byte)Commons.EProductType.Modifier, CurrentUser.ListOrganizationId);
                if (!string.IsNullOrEmpty(StoreId))
                {
                    result = result.Where(o => o.ListStore.Select(s => s.ID).ToList().Any(sID => sID.Equals(StoreId))).ToList();
                }
                result.ForEach(x =>
                {
                    x.ImageURL      = string.IsNullOrEmpty(x.ImageURL) ? Commons.Image100_100 : x.ImageURL;
                    x.ListStoreName = x.ListStore.Select(z => z.Name).ToList();
                    x.ListStoreName = x.ListStoreName.OrderBy(s => s).ToList();
                    x.StoreName     = string.Join(", ", x.ListStoreName);
                    x.CategoryName  = x.ListCategoryName != null ? x.ListCategoryName[0] : "";
                });
                model.ListItem = result;
            }
            catch (Exception ex)
            {
                NSLog.Logger.Error("LoadProductByStore", ex);
            }
            return(PartialView("_ItemProductExtend", model));
        }
예제 #2
0
        public ActionResult ExtendAll()
        {
            var model = new InteProductViewModels();

            //ViewBag.ListStoreTo = ViewBag.ListStore;
            model.ListStoreTo = (SelectList)ViewBag.StoreID;
            return(View(model));
        }
예제 #3
0
        // Updated 04192018, for list stores group by company
        public ActionResult LoadListStoreExtendTo(string StoreId)
        {
            // Return for new list stores extend
            InteProductViewModels model = new InteProductViewModels();
            var lstStoreView            = (List <StoreModels>)ViewBag.StoreID.Items;
            var temps = lstStoreView.Where(ww => ww.Id != StoreId).ToList();

            model.ListStoreTo = new SelectList(temps, "Id", "Name", "CompanyName", 1);
            return(PartialView("_LoadListStoreExtendTo", model));
        }
예제 #4
0
        public ActionResult ExtendAll(InteProductViewModels model)
        {
            try
            {
                if (string.IsNullOrEmpty(model.StoreID))
                {
                    ModelState.AddModelError("StoreID", CurrentUser.GetLanguageTextFromKey("Please choose store."));
                }

                if (model.ListStoreID == null || model.ListStoreID.Count == 0)
                {
                    ModelState.AddModelError("ListStoreID", CurrentUser.GetLanguageTextFromKey("Please choose store."));
                }

                if (model.ListItem == null || model.ListItem.Count(x => x.IsSelected) == 0)
                {
                    ModelState.AddModelError("ListItem", CurrentUser.GetLanguageTextFromKey("Please choose item."));
                }
                else
                {
                    model.IsCheckAll = model.ListItem.Count == model.ListItem.Count(x => x.IsSelected);
                }
                //var temp = ViewBag.ListStore as List<SelectListItem>;
                //var temps = temp.Where(x => x.Value != model.StoreID).Select(x => new SelectListItem { Value = x.Value, Text = x.Text }).ToList();
                //ViewBag.ListStoreTo = temps;

                // Return new ListStoreTo
                var lstStoreView = (List <StoreModels>)ViewBag.StoreID.Items;
                var temps        = lstStoreView.Where(ww => ww.Id != model.StoreID).ToList();
                model.ListStoreTo = new SelectList(temps, "Id", "Name", "CompanyName", 1);

                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                string msg = "";
                DishImportResultModels importModel = new DishImportResultModels();
                importModel.ListImport = _factory.ExtendProduct(model, ref msg);
                if (string.IsNullOrEmpty(msg))
                {
                    return(View("ExtendDetail", importModel));
                }
                else
                {
                    ModelState.AddModelError("StoreID", msg);
                    return(View(model));
                }
            }
            catch (Exception ex)
            {
                NSLog.Logger.Error("ExtendAll :", ex);
                return(new HttpStatusCodeResult(400, ex.Message));
            }
        }
예제 #5
0
 public ActionResult Index()
 {
     try
     {
         InteProductViewModels model = new InteProductViewModels();
         model.StoreID = CurrentUser.StoreId;
         return(View(model));
     }
     catch (Exception ex)
     {
         _logger.Error("Product_Modifier_Index: " + ex);
         return(new HttpStatusCodeResult(400, ex.Message));
     }
 }
예제 #6
0
        public ActionResult Search(InteProductViewModels model)
        {
            try
            {
                var result = _factory.GetListProduct((byte)Commons.EProductType.Modifier, CurrentUser.ListOrganizationId);
                if (model.ListStoreID != null && model.ListStoreID.Count > 0)
                {
                    List <InteProductLiteModels> tmp = new List <InteProductLiteModels>();
                    //for (int i = 0; i < result.Count; i++)
                    //{
                    //    bool IsExis = false;
                    //    for (int j = 0; j < model.ListStoreID.Count; j++)
                    //    {
                    //        var IsChecked = result[i].ListStore.Where(o => o.ID.Contains(model.ListStoreID[j])).FirstOrDefault();
                    //        if (IsChecked != null)
                    //        {
                    //            IsExis = true;
                    //            break;
                    //        }
                    //    }
                    //    if (IsExis == true)
                    //    {
                    //        tmp.Add(result[i]);
                    //    }
                    //}
                    //result = new List<InteProductLiteModels>();
                    //result.AddRange(tmp);

                    //result = result.Where(o => model.ListStoreID.Any(a => o.ListStore.Select(t => t.ID).ToList().Contains(a))).ToList();
                    result = result.Where(o => o.ListStore.Select(s => s.ID).ToList().Any(sID => model.ListStoreID.Contains(sID))).ToList();
                }
                result.ForEach(x =>
                {
                    x.ImageURL      = string.IsNullOrEmpty(x.ImageURL) ? Commons.Image100_100 : x.ImageURL;
                    x.ListStoreName = x.ListStore.Select(z => z.Name).ToList();
                    x.ListStoreName = x.ListStoreName.OrderBy(s => s).ToList();
                    x.StoreName     = string.Join(", ", x.ListStoreName);
                });
                model.ListItem = result;
            }
            catch (Exception e)
            {
                _logger.Error("Product_Modifier_Search: " + e);
                return(new HttpStatusCodeResult(400, e.Message));
            }
            return(PartialView("_ListData", model));
        }