public async Task <ActionResult> SetIndexSections(IndexSectionsModel ism)
        {
            try
            {
                IndexBoxInfoModel BoxInfo = ((List <IndexBoxInfoModel>)(await _indexboxinforepo.GetAll()).Data).FirstOrDefault(x => x.I_SecId == ism.Section && x.Lang == ism.Lang);

                if (BoxInfo == null)
                {
                    await _indexboxinforepo.Insert(new IndexBoxInfoModel()
                    {
                        I_SecId = ism.Section,
                        I_Title = ism.Title,
                        I_Icon  = ism.Icon,
                        I_Sort  = ism.Sort,
                        Lang    = ism.Lang
                    });

                    await _indexboxinforepo.CommitAllChanges();
                }
                else
                {
                    await _indexboxinforepo.Update(new IndexBoxInfoModel()
                    {
                        I_Id    = BoxInfo.I_Id,
                        I_SecId = ism.Section,
                        I_Title = ism.Title,
                        I_Icon  = ism.Icon,
                        I_Sort  = ism.Sort,
                        Lang    = ism.Lang
                    });

                    await _indexboxinforepo.CommitAllChanges();
                }
                List <IndexBoxProductRelModel> OldRelations = ((List <IndexBoxProductRelModel>)(await _indexsectionrepo.GetAll()).Data).Where(x => x.I_SecId == ism.Section && x.Lang == ism.Lang).ToList();
                foreach (var item in OldRelations)
                {
                    await _indexsectionrepo.Delete(item);
                }
                await _indexsectionrepo.CommitAllChanges();

                foreach (int p in ism.Products)
                {
                    await _indexsectionrepo.Insert(new IndexBoxProductRelModel()
                    {
                        Lang    = ism.Lang,
                        I_Pid   = p,
                        I_SecId = ism.Section
                    });
                }
                await _indexsectionrepo.CommitAllChanges();

                return(new JsonResult(ResponseModel.Success("اطلاعات با موفقیت ذخیره گردید")));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
 public async Task <ActionResult> GetIndexSections(IndexSectionsModel ism)
 {
     try
     {
         var box = ((List <IndexBoxInfoModel>)(await _indexboxinforepo.GetAll()).Data).Where(x => x.Lang == ism.Lang && x.I_SecId == ism.Section).ToList();
         if (box.Count() < 1)
         {
             return(new JsonResult(ResponseModel.Error(data: new { Products = new List <ProductModel>(), Info = "" })));
         }
         var PIds = ((List <IndexBoxProductRelModel>)(await _indexsectionrepo.GetAll()).Data).Where(x => x.Lang == ism.Lang && x.I_SecId == ism.Section).ToList();
         List <ProductModel> products = new List <ProductModel>();
         foreach (var p in PIds)
         {
             products.Add(await _productrepo.GetById(p.I_Pid));
         }
         return(new JsonResult(ResponseModel.Success(data: new { Products = products, Info = box.FirstOrDefault() })));
     }
     catch (Exception ex)
     {
         return(new JsonResult(ResponseModel.ServerInternalError(data: ex)));
     }
 }