コード例 #1
0
        public int UpdadteStatusOfPocket(int pocketId, int statusId)
        {
            PocketInfo pocketInfoToChangeStatus = GetPockeById(pocketId);

            pocketInfoToChangeStatus.PocketStatusId = statusId;
            return(UpdatePocket(pocketInfoToChangeStatus));
        }
コード例 #2
0
        public PocketInfoEntities GetPocketDetailForUpdate(int id)
        {
            IPocketInfoOperations pocketOperations = new PocketInfoOperations();
            PocketInfo            pocketInfo       = pocketOperations.GetPockeById(id);

            return(MapToBusinessEntityForUpdate(pocketInfo));
        }
コード例 #3
0
        public int DeletePocket(int pocketId)
        {
            PocketInfo pocketInfoToDelete = GetPockeById(pocketId);

            db.PocketInfoes.Remove(pocketInfoToDelete);
            return(db.SaveChanges());
        }
コード例 #4
0
        public int PutPocketDetail(PocketInfoEntities pocketInfoEntities)
        {
            IPocketInfoOperations              pocketOperations = new PocketInfoOperations();
            IPocketVillageMappingOperations    pocketVillageMappingOperations    = new PocketVillageMappingOperations();
            IPocketCropsMappingOperations      pocketCropMappingOperations       = new PocketCropsMappingOperations();
            IPocketFertilizerMappingOperations pocketFertilizerMappingOperations = new PocketFertilizerMappingOperations();

            PocketInfo pocketInfo = MapEntities.Map <PocketInfoEntities, PocketInfo>(pocketInfoEntities);
            List <PocketVillageMapping>    pocketVillageEntities     = MapEntities.MapList <PocketVillageMappingEntities, PocketVillageMapping>(pocketInfoEntities.PocketVillageMappingList);
            List <PocketCropMapping>       pocketCropsEntities       = MapEntities.MapList <PocketCropMappingEntities, PocketCropMapping>(pocketInfoEntities.PocketCropMappingList);
            List <PocketFertilizerMapping> pocketFertilizersEntities = MapEntities.MapList <PocketFertilizerMappingEntities, PocketFertilizerMapping>(pocketInfoEntities.PocketFertilizerMappingList);


            int UpdatedRecord = pocketOperations.UpdatePocket(pocketInfo);

            pocketVillageEntities.ForEach(x =>
            {
                x.PocketId = pocketInfo.PocketID;
            });
            pocketCropsEntities.ForEach(x =>
            {
                x.PocketId = pocketInfo.PocketID;
            });
            pocketFertilizersEntities.ForEach(x =>
            {
                x.PocketId = pocketInfo.PocketID;
            });

            pocketVillageMappingOperations.UpdatePocketVillageMappingOfPocket(pocketVillageEntities);
            pocketCropMappingOperations.UpdateCropsOfPocket(pocketCropsEntities);
            pocketFertilizerMappingOperations.UpdateFertilizersOfPocket(pocketFertilizersEntities);

            return(UpdatedRecord);
        }
コード例 #5
0
        public int PostPocketDetail(PocketInfoEntities pocketInfoEntities)
        {
            IPocketInfoOperations              pocketOperations = new PocketInfoOperations();
            IPocketVillageMappingOperations    pocketVillageMappingOperations    = new PocketVillageMappingOperations();
            IPocketCropsMappingOperations      pocketCropMappingOperations       = new PocketCropsMappingOperations();
            IPocketFertilizerMappingOperations pocketFertilizerMappingOperations = new PocketFertilizerMappingOperations();

            PocketInfo pocketInfo = MapEntities.Map <PocketInfoEntities, PocketInfo>(pocketInfoEntities);
            List <PocketVillageMapping>    pocketVillageEntities     = MapEntities.MapList <PocketVillageMappingEntities, PocketVillageMapping>(pocketInfoEntities.PocketVillageMappingList);
            List <PocketCropMapping>       pocketCropsEntities       = MapEntities.MapList <PocketCropMappingEntities, PocketCropMapping>(pocketInfoEntities.PocketCropMappingList);
            List <PocketFertilizerMapping> pocketFertilizersEntities = MapEntities.MapList <PocketFertilizerMappingEntities, PocketFertilizerMapping>(pocketInfoEntities.PocketFertilizerMappingList);

            int pocketId = pocketOperations.InsertPocket(pocketInfo);

            pocketVillageEntities.ForEach(x => { x.PocketId = pocketId; });
            pocketCropsEntities.ForEach(x => { x.PocketId = pocketId; });
            pocketFertilizersEntities.ForEach(x => { x.PocketId = pocketId; });

            pocketVillageMappingOperations.InsertPocketVillageMappingOfPocket(pocketVillageEntities);
            pocketCropMappingOperations.InsertCropsOfPocket(pocketCropsEntities);
            pocketFertilizerMappingOperations.InsertFertilizersOfPocket(pocketFertilizersEntities);


            return(pocketId);
        }
コード例 #6
0
 public int InsertPocket(PocketInfo pocketInfo)
 {
     pocketInfo.CreatedDate = DateTime.Now;
     pocketInfo.UpdatedDate = DateTime.Now;
     pocketInfo.CreatedBy   = pocketInfo.CreatedBy;
     db.PocketInfoes.Add(pocketInfo);
     db.SaveChanges();
     return(pocketInfo.PocketID);
 }
コード例 #7
0
        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);
        }
コード例 #8
0
        public int UpdatePocket(PocketInfo pocketInfo)
        {
            PocketInfo pocketInfoToUpdate = GetPockeById(pocketInfo.PocketID);

            pocketInfoToUpdate.PocketStatusId = pocketInfo.PocketStatusId;
            pocketInfoToUpdate.DistrictId     = pocketInfo.DistrictId;
            pocketInfoToUpdate.PocketName     = pocketInfo.PocketName;
            pocketInfoToUpdate.StateID        = pocketInfo.StateID;
            pocketInfoToUpdate.UpdatedDate    = DateTime.Now;
            pocketInfoToUpdate.UpdatedBy      = pocketInfo.UpdatedBy;
            return(db.SaveChanges());
        }
コード例 #9
0
        private PocketInfoEntities MapToBusinessEntity(PocketInfo pocketInfo)
        {
            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.Add(MapEntities.Map <StateInfo, StateInfoEntities>(pocketInfo.StateInfo));
            pocketInfoEntities.districts.Add(MapEntities.Map <DistrictInfo, DistrictInfoEntities>(pocketInfo.DistrictInfo));
            pocketInfoEntities.pocketStatusList.Add(MapEntities.Map <PocketStatu, PocketStatusEntities>(pocketInfo.PocketStatu));
            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.Add(MapEntities.Map <SubDistrictInfo, SubDistrictInfoEntities>(pocketMappingTemp.SubDistrictInfo));
                y.villages.Add(MapEntities.Map <VillageInfo, VillageInfoEntities>(pocketMappingTemp.VillageInfo));
            });

            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.Add(y.CropInfoEntity);
            });

            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.Add(y.FertilizerInfoEntity);
            });
            return(pocketInfoEntities);
        }
コード例 #10
0
        public PocketInfo GetPockeById(int pocketId)
        {
            PocketInfo pocketInfo = db.PocketInfoes.Select(x => x).Where(x => x.PocketID == pocketId).FirstOrDefault();

            return(pocketInfo);
        }