private PocketInfoEntities MapToBusinessEntityForUpdate(PocketInfo pocketInfo)
        {
            IStateInfoOperations       stateOperations       = new StateInfoOperations();
            IDistrictInfoOperations    districtOperations    = new DistrictInfoOperations();
            IsubDistrictInfoOperations subDistrictOperations = new SubDistrictInfoOperations();
            IVillageInfoOperations     villageOperations     = new VillageInfoOperations();
            ICropInfoOperations        cropOperations        = new CropInfoOperations();
            IFertilizerInfoOperations  fertilizerOperations  = new FertilizerInfoOperations();
            IPocketInfoOperations      pocketOperations      = new PocketInfoOperations();

            List <CropInfoEntities>       crops       = MapEntities.MapList <CropInfo, CropInfoEntities>(cropOperations.GetAllCrops().ToList());
            List <FertilizerInfoEntities> fertilizers = MapEntities.MapList <FertilizerInfo, FertilizerInfoEntities>(fertilizerOperations.GetFertilizerList());

            PocketInfoEntities pocketInfoEntities = MapEntities.Map <PocketInfo, PocketInfoEntities>(pocketInfo);

            pocketInfoEntities.StateName    = pocketInfo.StateInfo.StateName;
            pocketInfoEntities.DistrictName = pocketInfo.DistrictInfo.DistrictName;

            pocketInfoEntities.PocketVillageMappingList    = MapEntities.MapList <PocketVillageMapping, PocketVillageMappingEntities>(pocketInfo.PocketVillageMappings.ToList());
            pocketInfoEntities.PocketCropMappingList       = MapEntities.MapList <PocketCropMapping, PocketCropMappingEntities>(pocketInfo.PocketCropMappings.ToList());
            pocketInfoEntities.PocketFertilizerMappingList = MapEntities.MapList <PocketFertilizerMapping, PocketFertilizerMappingEntities>(pocketInfo.PocketFertilizerMappings.ToList());

            pocketInfoEntities.states           = MapEntities.MapList <StateInfo, StateInfoEntities>(stateOperations.GetAllStates());
            pocketInfoEntities.districts        = MapEntities.MapList <DistrictInfo, DistrictInfoEntities>(districtOperations.GetDistrictListByStateId(pocketInfoEntities.StateID.Value));
            pocketInfoEntities.pocketStatusList = MapEntities.MapList <PocketStatu, PocketStatusEntities>(pocketOperations.GetpocketStatusList());
            pocketInfoEntities.pocketStatus     = MapEntities.Map <PocketStatu, PocketStatusEntities>(pocketInfo.PocketStatu);

            PocketVillageMapping pocketMappingTemp;

            pocketInfoEntities.PocketVillageMappingList.ForEach(y =>
            {
                pocketMappingTemp = pocketInfo.PocketVillageMappings.Select(r => r).Where(r => r.Id == y.Id).FirstOrDefault();
                y.SubDistrictName = pocketMappingTemp.SubDistrictInfo.SubDistrictName;
                y.VillageName     = pocketMappingTemp.VillageInfo.VILLAGE;
                y.subDistricts    = MapEntities.MapList <SubDistrictInfo, SubDistrictInfoEntities>(subDistrictOperations.GetSubDistrictByDistrictId(pocketInfoEntities.DistrictId.Value));
                y.villages        = MapEntities.MapList <VillageInfo, VillageInfoEntities>(villageOperations.GetAllVillagesBySubDistrictId(y.SubDistrictId.Value));
            });

            PocketCropMapping pocketCropMappingTemp;

            pocketInfoEntities.PocketCropMappingList.ForEach(y =>
            {
                pocketCropMappingTemp = pocketInfo.PocketCropMappings.Select(r => r).Where(r => r.id == y.id).FirstOrDefault();
                y.CropInfoEntity      = MapEntities.Map <CropInfo, CropInfoEntities>(pocketInfo.PocketCropMappings.Select(r => r).Where(r => r.id == y.id).FirstOrDefault().CropInfo);
                y.Crops = crops;
            });

            PocketFertilizerMapping pocketFertilizerMappingTemp;

            pocketInfoEntities.PocketFertilizerMappingList.ForEach(y =>
            {
                pocketFertilizerMappingTemp = pocketInfo.PocketFertilizerMappings.Select(r => r).Where(r => r.Id == y.Id).FirstOrDefault();
                y.FertilizerInfoEntity      = MapEntities.Map <FertilizerInfo, FertilizerInfoEntities>(pocketInfo.PocketFertilizerMappings.Select(r => r).Where(r => r.Id == y.Id).FirstOrDefault().FertilizerInfo);
                y.Fertilizers = fertilizers;
            });
            return(pocketInfoEntities);
        }
 public List <VillageInfoEntities> GetVillageInfoBySubDistrictId(int subDistrictId)
 {
     try
     {
         IVillageInfoOperations     villageInfoOperation = new VillageInfoOperations();
         List <VillageInfoEntities> villageList          = MapEntities.MapIEnumerableCollection <VillageInfo, VillageInfoEntities>(villageInfoOperation.GetAllVillagesBySubDistrictId(subDistrictId)).ToList();
         return(villageList);
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Exemple #3
0
        public FarmerDetailPageUIvalues GetPocketMappingData(int id)
        {
            FarmerDetailPageUIvalues pageUIvalues = new FarmerDetailPageUIvalues();

            ICropInfoOperations cropInfoOperations = new CropInfoOperations();

            pageUIvalues.CropList = MapEntities.MapList <CropInfo, CropInfoEntities>(cropInfoOperations.GetCropListOfPocket(id).ToList());

            IVillageInfoOperations villageOperation = new VillageInfoOperations();

            pageUIvalues.villageList = MapEntities.MapList <VillageInfo, VillageInfoEntities>(villageOperation.GetVillageListOfPocket(id)).ToList();

            return(pageUIvalues);
        }