Ejemplo n.º 1
0
        public IEnumerable <ProductDetailResult> GetAllASMasterSubCategoryEmployee(long MasterEmployeeId)
        {
            try
            {
                var _data = (from MC in _Context.ASMasterCategories
                             join MSC in _Context.ASMasterSubCategories on MC.MasterCategoryId equals MSC.MasterCategoryId
                             join MP in _Context.ASMasterProducts on MSC.MasterSubCategoryId equals MP.MasterSubCategoryId into MPGroup
                             from MP in MPGroup.DefaultIfEmpty()
                             join MPC in _Context.ASMasterProductChilds on MP.MasterProductId equals MPC.MasterProductId into MPCGroup
                             from MPC in MPCGroup.DefaultIfEmpty()
                             where MPC.MasterEmployeeId == MasterEmployeeId
                             select new
                {
                    MC.MasterCategoryId,
                    MC.CategoryTitle,
                    MSC.MasterSubCategoryId,
                    MSC.SubCategoryTitle,
                    MPC.ProductChildTitle,
                    MPC.ProductChildSKU,
                    MPC.ManufacturerPartNumber,
                    MPC.PurchasePrice,
                    MPC.DepreciatePrice,
                    MPC.IsActive,
                    MPC.IsDeadAssets,
                    MPC.IsSaleProduct,
                    MPC.MasterBranchId,
                    MPC.MasterEmployeeId
                });

                List <ProductDetailResult> objProductDetailResultList = new List <ProductDetailResult>();

                foreach (var _Item in _data.ToList())
                {
                    var _ProductDetailResult = new ProductDetailResult();

                    _ProductDetailResult.MasterSubCategoryId    = _Item.MasterSubCategoryId;
                    _ProductDetailResult.SubCategoryTitle       = _Item.SubCategoryTitle;
                    _ProductDetailResult.MasterCategoryId       = _Item.MasterCategoryId;
                    _ProductDetailResult.CategoryTitle          = _Item.CategoryTitle;
                    _ProductDetailResult.ProductChildTitle      = _Item.ProductChildTitle;
                    _ProductDetailResult.ProductChildSKU        = _Item.ProductChildSKU;
                    _ProductDetailResult.ManufacturerPartNumber = _Item.ManufacturerPartNumber;

                    _ProductDetailResult.TotalAssetsInStock = (_data.Where(a => a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _ProductDetailResult.AssetsAssign       = (_data.Where(a => a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false && (a.MasterEmployeeId != 0)).Count());
                    _ProductDetailResult.AssetsInRepair     = (_data.Where(a => a.IsActive == false && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());

                    _ProductDetailResult.TotalAssetsCost             = _Item.PurchasePrice ?? 0;
                    _ProductDetailResult.TotalAssetsDepreciatedValue = _Item.DepreciatePrice ?? 0;

                    objProductDetailResultList.Add(_ProductDetailResult);
                }
                return(objProductDetailResultList.Where(a => a.TotalAssetsInStock > 0 || a.AssetsAssign > 0 || a.AssetsInRepair > 0 || a.ServiceInExpire > 0).ToList());
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 2
0
        public IEnumerable <MasterCategoryResult> GetAllASMasterCategory()
        {
            try
            {
                var _data = (from MC in _Context.ASMasterCategories

                             select new
                {
                    MC.MasterCategoryId,
                    MC.CategoryCode,
                    MC.CategoryTitle,
                    MC.MasterCategoryType,
                    MC.MasterCategoryDescription,
                    MC.CategoryImage,
                    MC.Sequence,
                    MC.IsActive,
                    MC.EnterById,
                    MC.EnterDate,
                    MC.ModifiedById,
                    MC.ModifiedDate,
                });

                var _Productdata = (from MC in _Context.ASMasterCategories
                                    join MSC in _Context.ASMasterSubCategories on MC.MasterCategoryId equals MSC.MasterCategoryId
                                    join MP in _Context.ASMasterProducts on MSC.MasterSubCategoryId equals MP.MasterSubCategoryId into MPGroup
                                    from MP in MPGroup.DefaultIfEmpty()
                                    join MPC in _Context.ASMasterProductChilds on MP.MasterProductId equals MPC.MasterProductId into MPCGroup
                                    from MPC in MPCGroup.DefaultIfEmpty()
                                    select new
                {
                    MC.MasterCategoryId,
                    MC.CategoryTitle,
                    MSC.MasterSubCategoryId,
                    MSC.SubCategoryTitle,
                    MPC.ProductChildTitle,
                    MPC.ProductChildSKU,
                    MPC.ManufacturerPartNumber,
                    MPC.PurchasePrice,
                    MPC.DepreciatePrice,
                    MPC.IsActive,
                    MPC.IsDeadAssets,
                    MPC.IsSaleProduct,
                    MPC.MasterBranchId,
                    MPC.MasterEmployeeId,
                    MPC.WarrantyExpiryDate
                });

                List <MasterCategoryResult> objMasterCategoryResulttList = new List <MasterCategoryResult>();

                foreach (var _Item in _data.ToList())
                {
                    var _MasterCategoryResult = new MasterCategoryResult();

                    _MasterCategoryResult.MasterCategoryId          = _Item.MasterCategoryId;
                    _MasterCategoryResult.CategoryCode              = _Item.CategoryCode;
                    _MasterCategoryResult.CategoryTitle             = _Item.CategoryTitle;
                    _MasterCategoryResult.MasterCategoryType        = _Item.MasterCategoryType;
                    _MasterCategoryResult.MasterCategoryDescription = _Item.MasterCategoryDescription;
                    _MasterCategoryResult.CategoryImage             = _Item.CategoryImage;

                    _MasterCategoryResult.Sequence     = _Item.Sequence;
                    _MasterCategoryResult.IsActive     = _Item.IsActive;
                    _MasterCategoryResult.EnterById    = _Item.EnterById;
                    _MasterCategoryResult.EnterDate    = _Item.EnterDate;
                    _MasterCategoryResult.ModifiedById = _Item.ModifiedById;
                    _MasterCategoryResult.ModifiedDate = _Item.ModifiedDate;

                    _MasterCategoryResult.TotalAssetsInStock          = (_Productdata.Where(a => a.MasterCategoryId == _Item.MasterCategoryId && a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _MasterCategoryResult.AssetsAssign                = (_Productdata.Where(a => a.MasterCategoryId == _Item.MasterCategoryId && a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false && (a.MasterEmployeeId != 0)).Count());
                    _MasterCategoryResult.AssetsInRepair              = (_Productdata.Where(a => a.MasterCategoryId == _Item.MasterCategoryId && a.IsActive == false && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _MasterCategoryResult.ServiceInExpire             = (_Productdata.Where(a => a.MasterCategoryId == _Item.MasterCategoryId && a.WarrantyExpiryDate <= DateTime.Now && a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _MasterCategoryResult.AssetsInSold                = (_Productdata.Where(a => a.MasterCategoryId == _Item.MasterCategoryId && a.IsActive == false && a.IsDeadAssets == false && a.IsSaleProduct == true).Count());
                    _MasterCategoryResult.AssetsInDead                = (_Productdata.Where(a => a.MasterCategoryId == _Item.MasterCategoryId && a.WarrantyExpiryDate <= DateTime.Now && a.IsActive == true && a.IsDeadAssets == true && a.IsSaleProduct == false).Count());
                    _MasterCategoryResult.TotalAssetsCost             = (_Productdata.Where(a => a.MasterCategoryId == _Item.MasterCategoryId && a.IsDeadAssets == false && a.IsSaleProduct == false).Sum(a => a.PurchasePrice) ?? 0);
                    _MasterCategoryResult.TotalAssetsDepreciatedValue = (_Productdata.Where(a => a.MasterCategoryId == _Item.MasterCategoryId && a.IsDeadAssets == false && a.IsSaleProduct == false).Sum(a => a.DepreciatePrice) ?? 0);

                    objMasterCategoryResulttList.Add(_MasterCategoryResult);
                }
                return(objMasterCategoryResulttList);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 3
0
        public IEnumerable <MasterProductResult> GetASMasterProductByID(long MasterCategoryId, long MasterSubCategoryId, long MasterBrandId)
        {
            try
            {
                //Get Parent Product data as per MasterCategoryId Or MasterSubCategoryId Or  MasterBranchId
                var _data = (from MP in _Context.ASMasterProducts
                             join MB in _Context.ASMasterBrands on MP.MasterBrandId equals MB.MasterBrandId into MBGroup
                             from MB in MBGroup.DefaultIfEmpty()
                             join SC in _Context.ASMasterSubCategories on MP.MasterSubCategoryId equals SC.MasterSubCategoryId into SCGroup
                             from SC in SCGroup.DefaultIfEmpty()
                             join CA in _Context.ASMasterCategories on SC.MasterCategoryId equals CA.MasterCategoryId into CAGroup
                             from CA in CAGroup.DefaultIfEmpty()
                             where (MasterCategoryId > 0 && MasterSubCategoryId == 0 && MasterBrandId == 0 && SC.MasterCategoryId == MasterCategoryId) ||
                             (MasterCategoryId == 0 && MasterSubCategoryId > 0 && MasterBrandId == 0 && MP.MasterSubCategoryId == MasterSubCategoryId) ||
                             (MasterCategoryId == 0 && MasterSubCategoryId == 0 && MasterBrandId > 0 && MP.MasterBrandId == MasterBrandId)
                             select new
                {
                    MP.MasterProductId,
                    MP.ProductTitle,
                    MP.ProductSKU,
                    MP.ProductHSNCode,
                    MP.ProductBarCode,
                    MP.ProductMainImage,
                    MP.Description,
                    MP.Specification,
                    MP.LegalDisclamer,
                    MP.SafetyWarning,
                    MP.ProductModel,
                    MP.Manufacturer,
                    MP.DepreciatePercentage,
                    MP.ReorderLevel,
                    MP.CountryOfOrigin,
                    //CO.CountryTitle,
                    MP.ProductTaxCode,
                    //MT.TaxTitle,
                    //MT.IsTaxPercentageAmount,
                    //MT.TaxValue,
                    MP.ProductCurrency,
                    //MC.CurrencyTitle,
                    MP.Sequence,
                    MP.IsActive,
                    MP.EnterById,
                    MP.EnterDate,
                    MP.ModifiedById,
                    MP.ModifiedDate,
                    MP.MasterBrandId,
                    MB.BrandTitle,
                    MP.MasterSubCategoryId,
                    SC.SubCategoryTitle,
                    CA.CategoryTitle,
                    CA.MasterCategoryId
                });

                var _AdminCountries  = _AdminContext.ADMasterCountries.ToList();
                var _AdminTaxes      = _AdminContext.ADMasterTaxes.ToList();
                var _AdminCurrencies = _AdminContext.ADMasterCurrencies.ToList();
                var _AdminBranches   = _AdminContext.ADMasterBranches.ToList();
                var _AdminEmployees  = _AdminContext.ADMasterEmployees.ToList();
                var _AdminVendors    = _AdminContext.ADMasterVendors.ToList();

                //Get Child Product data as per MasterCategoryId Or MasterSubCategoryId Or  MasterBranchId
                var _Productdata = (from MC in _Context.ASMasterCategories
                                    join MSC in _Context.ASMasterSubCategories on MC.MasterCategoryId equals MSC.MasterCategoryId
                                    join MP in _Context.ASMasterProducts on MSC.MasterSubCategoryId equals MP.MasterSubCategoryId into MPGroup
                                    from MP in MPGroup.DefaultIfEmpty()
                                    join MPC in _Context.ASMasterProductChilds on MP.MasterProductId equals MPC.MasterProductId into MPCGroup
                                    from MPC in MPCGroup.DefaultIfEmpty()
                                    where (MasterCategoryId > 0 && MasterSubCategoryId == 0 && MasterBrandId == 0 && MSC.MasterCategoryId == MasterCategoryId) ||
                                    (MasterCategoryId == 0 && MasterSubCategoryId > 0 && MasterBrandId == 0 && MP.MasterSubCategoryId == MasterSubCategoryId) ||
                                    (MasterCategoryId == 0 && MasterSubCategoryId == 0 && MasterBrandId > 0 && MP.MasterBrandId == MasterBrandId)
                                    select new
                {
                    MC.MasterCategoryId,
                    MC.CategoryTitle,
                    MSC.MasterSubCategoryId,
                    MSC.SubCategoryTitle,
                    MPC.MasterProductId,
                    MPC.ProductChildTitle,
                    MPC.ProductChildSKU,
                    MPC.ManufacturerPartNumber,
                    MPC.PurchasePrice,
                    MPC.DepreciatePrice,
                    MPC.IsActive,
                    MPC.IsDeadAssets,
                    MPC.IsSaleProduct,
                    MPC.MasterBranchId,
                    MPC.MasterEmployeeId,
                    MPC.WarrantyExpiryDate
                });

                //insert search data in model List<MasterProductResult> object with parent and child
                List <MasterProductResult> objMasterProductResultList = new List <MasterProductResult>();

                foreach (var _Item in _data.ToList())
                {
                    MasterProductResult _MasterProductResult = new MasterProductResult();
                    _MasterProductResult.MasterProductId      = _Item.MasterProductId;
                    _MasterProductResult.ProductTitle         = _Item.ProductTitle;
                    _MasterProductResult.MasterBrandId        = _Item.MasterBrandId;
                    _MasterProductResult.BrandTitle           = _Item.BrandTitle;
                    _MasterProductResult.MasterSubCategoryId  = _Item.MasterSubCategoryId;
                    _MasterProductResult.SubCategoryTitle     = _Item.SubCategoryTitle;
                    _MasterProductResult.MasterCategoryId     = _Item.MasterCategoryId;
                    _MasterProductResult.CategoryTitle        = _Item.CategoryTitle;
                    _MasterProductResult.ProductSKU           = _Item.ProductSKU;
                    _MasterProductResult.ProductHSNCode       = _Item.ProductHSNCode;
                    _MasterProductResult.ProductBarCode       = _Item.ProductBarCode;
                    _MasterProductResult.ProductMainImage     = _Item.ProductMainImage;
                    _MasterProductResult.Description          = _Item.Description;
                    _MasterProductResult.Specification        = _Item.Specification;
                    _MasterProductResult.LegalDisclamer       = _Item.LegalDisclamer;
                    _MasterProductResult.SafetyWarning        = _Item.SafetyWarning;
                    _MasterProductResult.ProductModel         = _Item.ProductModel;
                    _MasterProductResult.Manufacturer         = _Item.Manufacturer;
                    _MasterProductResult.DepreciatePercentage = _Item.DepreciatePercentage;
                    _MasterProductResult.ReorderLevel         = _Item.ReorderLevel;
                    _MasterProductResult.CountryOfOrigin      = _Item.CountryOfOrigin;
                    _MasterProductResult.CountryOfOriginTitle = _AdminCountries.Where(a => a.MasterCountryId == _Item.CountryOfOrigin).Select(a => a.CountryTitle).FirstOrDefault();
                    _MasterProductResult.ProductTaxCode       = _Item.ProductTaxCode;
                    _MasterProductResult.ProductTaxCodeTitle  = _AdminTaxes.Where(a => a.MasterTaxId == _Item.ProductTaxCode).Select(a => a.TaxTitle).FirstOrDefault();
                    _MasterProductResult.ProductCurrency      = _Item.ProductCurrency;
                    _MasterProductResult.ProductCurrencyTitle = _AdminCurrencies.Where(a => a.MasterCurrencyId == _Item.ProductCurrency).Select(a => a.CurrencyTitle).FirstOrDefault();;

                    _MasterProductResult.TotalAssetsInStock          = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _MasterProductResult.AssetsAssign                = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false && (a.MasterEmployeeId != 0)).Count());
                    _MasterProductResult.AssetsInRepair              = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == false && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _MasterProductResult.ServiceInExpire             = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.WarrantyExpiryDate <= DateTime.Now && a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _MasterProductResult.AssetsInSold                = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == false && a.IsDeadAssets == false && a.IsSaleProduct == true).Count());
                    _MasterProductResult.AssetsInDead                = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == false && a.IsDeadAssets == true && a.IsSaleProduct == false).Count());
                    _MasterProductResult.TotalAssetsCost             = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsDeadAssets == false && a.IsSaleProduct == false).Sum(a => a.PurchasePrice) ?? 0);
                    _MasterProductResult.TotalAssetsDepreciatedValue = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsDeadAssets == false && a.IsSaleProduct == false).Sum(a => a.DepreciatePrice) ?? 0);

                    _MasterProductResult.Sequence      = _Item.Sequence;
                    _MasterProductResult.IsActive      = _Item.IsActive;
                    _MasterProductResult.EnterById     = _Item.EnterById;
                    _MasterProductResult.EnterDate     = _Item.EnterDate;
                    _MasterProductResult.ModifiedById  = _Item.ModifiedById;
                    _MasterProductResult.ModifiedDate  = _Item.ModifiedDate;
                    _MasterProductResult.MaxProductSKU = _Context.ASMasterProductChilds.Where(a => a.MasterProductId == _Item.MasterProductId).Max(a => a.ProductChildSKU);

                    objMasterProductResultList.Add(_MasterProductResult);

                    var _dataChild = (from MPC in _Context.ASMasterProductChilds
                                      join MAA in _Context.ASMasterAssetsAssignments on MPC.MasterProductChildId equals MAA.MasterProductChildId into MAAGroup
                                      from MAA in MAAGroup.DefaultIfEmpty()
                                      where MPC.MasterProductId == _Item.MasterProductId
                                      select new
                    {
                        MPC.MasterProductChildId,
                        MPC.MasterProductId,
                        MPC.ProductChildSKU,
                        MPC.ManufacturerPartNumber,
                        MPC.PurchaseDate,
                        MPC.PurchasePrice,
                        MPC.DepreciatePrice,
                        MPC.WarrantyExpiryDate,
                        MPC.WarrantyStartDate,
                        MPC.IterationOfWarranty,
                        MPC.MasterBranchId,
                        MPC.MasterEmployeeId,
                        MPC.MasterVendorId,
                        MPC.IsDeadAssets,
                        MPC.IsSaleProduct,
                        MPC.IsActive,
                        MasterAssetsAssignmentId = (MAA.MasterAssetsAssignmentId != null ? MAA.MasterAssetsAssignmentId : 0),
                        MAA.AssetsAssignmentDate,
                        MAA.IsAssetsDeAssign
                    });


                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    List <MasterProductAssignChildResult> objMasterProductAssignChildResultList = new List <MasterProductAssignChildResult>();
                    foreach (var _ItemChild in _dataChild.ToList())
                    {
                        MasterProductAssignChildResult _MasterProductAssignChildResult = new MasterProductAssignChildResult();

                        _MasterProductAssignChildResult.MasterProductChildId   = _ItemChild.MasterProductChildId;
                        _MasterProductAssignChildResult.MasterProductId        = _ItemChild.MasterProductId;
                        _MasterProductAssignChildResult.ProductChildSKU        = _ItemChild.ProductChildSKU;
                        _MasterProductAssignChildResult.ManufacturerPartNumber = _ItemChild.ManufacturerPartNumber;
                        _MasterProductAssignChildResult.PurchaseDate           = _ItemChild.PurchaseDate;
                        _MasterProductAssignChildResult.PurchasePrice          = _ItemChild.PurchasePrice;
                        _MasterProductAssignChildResult.DepreciatePrice        = _ItemChild.DepreciatePrice;
                        _MasterProductAssignChildResult.WarrantyExpiryDate     = _ItemChild.WarrantyExpiryDate;
                        _MasterProductAssignChildResult.WarrantyStartDate      = _ItemChild.WarrantyStartDate;
                        _MasterProductAssignChildResult.IterationOfWarranty    = _ItemChild.IterationOfWarranty;
                        _MasterProductAssignChildResult.IsActive                 = _ItemChild.IsActive;
                        _MasterProductAssignChildResult.IsDeadAssets             = _ItemChild.IsDeadAssets;
                        _MasterProductAssignChildResult.IsSaleProduct            = _ItemChild.IsSaleProduct;
                        _MasterProductAssignChildResult.MasterBranchId           = _ItemChild.MasterBranchId;
                        _MasterProductAssignChildResult.BranchTitle              = _AdminBranches.Where(a => a.MasterBranchId == _ItemChild.MasterBranchId).Select(a => a.BranchTitle).FirstOrDefault();
                        _MasterProductAssignChildResult.MasterEmployeeId         = _ItemChild.MasterEmployeeId;
                        _MasterProductAssignChildResult.EmployeeName             = _AdminEmployees.Where(a => a.MasterEmployeeId == _ItemChild.MasterEmployeeId).Select(a => a.EmployeeName).FirstOrDefault();
                        _MasterProductAssignChildResult.MasterAssetsAssignmentId = _ItemChild.MasterAssetsAssignmentId;
                        _MasterProductAssignChildResult.AssetsAssignmentDate     = _ItemChild.AssetsAssignmentDate;
                        _MasterProductAssignChildResult.MasterVendorId           = _ItemChild.MasterVendorId;
                        _MasterProductAssignChildResult.VendorTitle              = _AdminVendors.Where(a => a.MasterVendorId == _ItemChild.MasterVendorId).Select(a => a.VendorTitle).FirstOrDefault();;
                        _MasterProductAssignChildResult.IsAssetsDeAssign         = _ItemChild.IsAssetsDeAssign;

                        objMasterProductAssignChildResultList.Add(_MasterProductAssignChildResult);
                    }
                    _MasterProductResult.ProductAssignChildList = objMasterProductAssignChildResultList;
                }

                return(objMasterProductResultList);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 4
0
        public IEnumerable <MasterProductResult> GetAllASMasterProduct()
        {
            try
            {
                var _data = (from MP in _Context.ASMasterProducts
                             join MB in _Context.ASMasterBrands on MP.MasterBrandId equals MB.MasterBrandId into MBGroup
                             from MB in MBGroup.DefaultIfEmpty()
                             join SC in _Context.ASMasterSubCategories on MP.MasterSubCategoryId equals SC.MasterSubCategoryId into SCGroup
                             from SC in SCGroup.DefaultIfEmpty()
                             join CA in _Context.ASMasterCategories on SC.MasterCategoryId equals CA.MasterCategoryId into CAGroup
                             from CA in CAGroup.DefaultIfEmpty()
                             select new
                {
                    MP.MasterProductId,
                    MP.ProductTitle,
                    MP.ProductSKU,
                    MP.ProductHSNCode,
                    MP.ProductBarCode,
                    MP.ProductMainImage,
                    MP.Description,
                    MP.Specification,
                    MP.LegalDisclamer,
                    MP.SafetyWarning,
                    MP.ProductModel,
                    MP.Manufacturer,
                    MP.DepreciatePercentage,
                    MP.ReorderLevel,
                    MP.CountryOfOrigin,
                    //CO.CountryTitle,
                    MP.ProductTaxCode,
                    //MT.TaxTitle,
                    //MT.IsTaxPercentageAmount,
                    //MT.TaxValue,
                    MP.ProductCurrency,
                    //MC.CurrencyTitle,
                    MP.Sequence,
                    MP.IsActive,
                    MP.EnterById,
                    MP.EnterDate,
                    MP.ModifiedById,
                    MP.ModifiedDate,
                    MP.MasterBrandId,
                    MB.BrandTitle,
                    MP.MasterSubCategoryId,
                    SC.SubCategoryTitle,
                    CA.CategoryTitle,
                    CA.MasterCategoryId
                    //TotalAssets = 2,
                    //AssetsAllocated = 1
                }).ToList();

                var _Productdata = (from MC in _Context.ASMasterCategories
                                    join MSC in _Context.ASMasterSubCategories on MC.MasterCategoryId equals MSC.MasterCategoryId
                                    join MP in _Context.ASMasterProducts on MSC.MasterSubCategoryId equals MP.MasterSubCategoryId into MPGroup
                                    from MP in MPGroup.DefaultIfEmpty()
                                    join MPC in _Context.ASMasterProductChilds on MP.MasterProductId equals MPC.MasterProductId into MPCGroup
                                    from MPC in MPCGroup.DefaultIfEmpty()
                                    select new
                {
                    MC.MasterCategoryId,
                    MC.CategoryTitle,
                    MSC.MasterSubCategoryId,
                    MSC.SubCategoryTitle,
                    MPC.MasterProductId,
                    MPC.ProductChildTitle,
                    MPC.ProductChildSKU,
                    MPC.ManufacturerPartNumber,
                    MPC.PurchasePrice,
                    MPC.DepreciatePrice,
                    MPC.IsActive,
                    MPC.IsDeadAssets,
                    MPC.IsSaleProduct,
                    MPC.MasterBranchId,
                    MPC.MasterEmployeeId,
                    MPC.WarrantyExpiryDate
                });

                var _AdminCountries  = _AdminContext.ADMasterCountries.ToList();
                var _AdminTaxes      = _AdminContext.ADMasterTaxes.ToList();
                var _AdminCurrencies = _AdminContext.ADMasterCurrencies.ToList();

                List <MasterProductResult> objMasterProductResultList = new List <MasterProductResult>();

                foreach (var _Item in _data.ToList())
                {
                    var _MasterProductResult = new MasterProductResult();

                    _MasterProductResult.MasterProductId      = _Item.MasterProductId;
                    _MasterProductResult.ProductTitle         = _Item.ProductTitle;
                    _MasterProductResult.MasterBrandId        = _Item.MasterBrandId;
                    _MasterProductResult.BrandTitle           = _Item.BrandTitle;
                    _MasterProductResult.MasterSubCategoryId  = _Item.MasterSubCategoryId;
                    _MasterProductResult.SubCategoryTitle     = _Item.SubCategoryTitle;
                    _MasterProductResult.MasterCategoryId     = _Item.MasterCategoryId;
                    _MasterProductResult.CategoryTitle        = _Item.CategoryTitle;
                    _MasterProductResult.ProductSKU           = _Item.ProductSKU;
                    _MasterProductResult.ProductHSNCode       = _Item.ProductHSNCode;
                    _MasterProductResult.ProductBarCode       = _Item.ProductBarCode;
                    _MasterProductResult.ProductMainImage     = _Item.ProductMainImage;
                    _MasterProductResult.Description          = _Item.Description;
                    _MasterProductResult.Specification        = _Item.Specification;
                    _MasterProductResult.LegalDisclamer       = _Item.LegalDisclamer;
                    _MasterProductResult.SafetyWarning        = _Item.SafetyWarning;
                    _MasterProductResult.ProductModel         = _Item.ProductModel;
                    _MasterProductResult.Manufacturer         = _Item.Manufacturer;
                    _MasterProductResult.DepreciatePercentage = _Item.DepreciatePercentage;
                    _MasterProductResult.ReorderLevel         = _Item.ReorderLevel;
                    _MasterProductResult.CountryOfOrigin      = _Item.CountryOfOrigin;
                    _MasterProductResult.CountryOfOriginTitle = _AdminCountries.Where(a => a.MasterCountryId == _Item.CountryOfOrigin).Select(a => a.CountryTitle).FirstOrDefault();
                    _MasterProductResult.ProductTaxCode       = _Item.ProductTaxCode;
                    _MasterProductResult.ProductTaxCodeTitle  = _AdminTaxes.Where(a => a.MasterTaxId == _Item.ProductTaxCode).Select(a => a.TaxTitle).FirstOrDefault();
                    _MasterProductResult.ProductCurrency      = _Item.ProductCurrency;
                    _MasterProductResult.ProductCurrencyTitle = _AdminCurrencies.Where(a => a.MasterCurrencyId == _Item.ProductCurrency).Select(a => a.CurrencyTitle).FirstOrDefault();;
                    _MasterProductResult.Sequence             = _Item.Sequence;

                    _MasterProductResult.TotalAssetsInStock          = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _MasterProductResult.AssetsAssign                = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false && (a.MasterEmployeeId != 0)).Count());
                    _MasterProductResult.AssetsInRepair              = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == false && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _MasterProductResult.ServiceInExpire             = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.WarrantyExpiryDate <= DateTime.Now && a.IsActive == true && a.IsDeadAssets == false && a.IsSaleProduct == false).Count());
                    _MasterProductResult.AssetsInSold                = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == false && a.IsDeadAssets == false && a.IsSaleProduct == true).Count());
                    _MasterProductResult.AssetsInDead                = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsActive == false && a.IsDeadAssets == true && a.IsSaleProduct == false).Count());
                    _MasterProductResult.TotalAssetsCost             = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsDeadAssets == false && a.IsSaleProduct == false).Sum(a => a.PurchasePrice) ?? 0);
                    _MasterProductResult.TotalAssetsDepreciatedValue = (_Productdata.Where(a => a.MasterProductId == _Item.MasterProductId && a.IsDeadAssets == false && a.IsSaleProduct == false).Sum(a => a.DepreciatePrice) ?? 0);


                    _MasterProductResult.IsActive     = _Item.IsActive;
                    _MasterProductResult.EnterById    = _Item.EnterById;
                    _MasterProductResult.EnterDate    = _Item.EnterDate;
                    _MasterProductResult.ModifiedById = _Item.ModifiedById;
                    _MasterProductResult.ModifiedDate = _Item.ModifiedDate;

                    objMasterProductResultList.Add(_MasterProductResult);
                }
                return(objMasterProductResultList.ToList());
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }