public IList<SlsSalesReturnViewModel> GetAllVM(int companyId)
        {
            try
            {
                IList<SlsSalesReturnViewModel> list = new List<SlsSalesReturnViewModel>();

                var listT = _SalesReturnRepository.GetAll().ToList();
                if (listT != null && listT.Count() > 0)
                {
                    foreach (SlsSalesReturn item in listT)
                    {
                        SlsSalesReturnViewModel obj = SlsSalesReturnMapModelToVM.MapToSlsSalesReturn(item);

                        //
                        IList<SlsProduct> productList = new ChartOfProductService(new ChartOfProductRepository(new DatabaseFactory()),
                    new UnitOfWork(new DatabaseFactory())).GetAll(companyId).ToList();

                        IList<SlsUnit> unitList = new UnitOfMeasurementService(new UnitOfMeasurementRepository(new DatabaseFactory()),
                            new UnitOfWork(new DatabaseFactory())).GetAll().ToList();

                        IList<SlsSalesReturnDetail> detailList = _SalesReturnDetailRepository.GetAll().ToList();

                        //Detail list
                        IList<SlsSalesReturnDetailViewModel> detailsOfObj = GetAllDetails(companyId, obj.Id,
                            productList, unitList, detailList);
                        obj.DetailList = detailsOfObj;

                        list.Add(obj);
                    }
                }

                return list;
            }
            catch (Exception ex)
            {
                return null;
            }
        }
        public ActionResult GetAllFreeProducts(int companyId)
        {
            string cmpny = Session["CompanyId"].ToString();
            var dbfactory = new DatabaseFactory();
            ChartOfProductService _ChartOfProductService = new ChartOfProductService(new ChartOfProductRepository(dbfactory), new UnitOfWork(dbfactory));
            var productlist = _ChartOfProductService.GetProducts(int.Parse(cmpny));

            var list = _FreeProductService.GetAll(int.Parse(cmpny)).ToList();

            List<SlsProduct> records = new List<SlsProduct>();
            foreach (SlsFreeProductsViewModel record in list)
            {
                var rec = productlist.Where(t => t.Id == record.SlsProductId).FirstOrDefault();
                if (rec != null)
                {
                    var isExist = records.Where(t => t.Id == rec.Id).FirstOrDefault();
                    if (isExist == null)
                    {
                        records.Add(rec);
                    }
                }
            }

            return Json(records, JsonRequestBehavior.AllowGet);
        }