public void DeleteGovernorate(Governorate entity)
 {
     if (entity != null)
     {
         repository.Delete(entity);
     }
 }
        public async Task<IActionResult> Edit(int id, [Bind("Id,Name")] Governorate governorate)
        {
            if (id != governorate.Id)
            {
                return NotFound();
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(governorate);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GovernorateExists(governorate.Id))
                    {
                        return NotFound();
                    }
                    else
                    {
                        throw;
                    }
                }
                return RedirectToAction(nameof(Index));
            }
            return View(governorate);
        }
 public void UpdateGovernorate(Governorate entity)
 {
     if (entity != null)
     {
         repository.Update(entity);
     }
 }
 public void InsertGovernorate(Governorate entity)
 {
     if (entity != null)
     {
         repository.Insert(entity);
     }
 }
Пример #5
0
 public static GovernorateEditViewModel ToEditViewModel(this Governorate model)
 {
     return(new GovernorateEditViewModel()
     {
         ID = model.ID,
         Name = model.Name,
     });
 }
        public ActionResult DeleteConfirmed(int id)
        {
            Governorate governorate = db.Governorates.Find(id);

            db.Governorates.Remove(governorate);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #7
0
 public static GovernorateViewModel ToViewModel(this Governorate model)
 {
     return(new GovernorateViewModel()
     {
         ID = model.ID,
         Name = model.Name,
         Neighborhoods = model?.Neighborhoods.ToList()
     });
 }
 public async Task<IActionResult> Create([Bind("Id,Name")] Governorate governorate)
 {
     if (ModelState.IsValid)
     {
         _context.Add(governorate);
         await _context.SaveChangesAsync();
         return RedirectToAction(nameof(Index));
     }
     return View(governorate);
 }
 public ActionResult Edit([Bind(Include = "ID,Name")] Governorate governorate)
 {
     if (ModelState.IsValid)
     {
         db.Entry(governorate).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(governorate));
 }
 public ActionResult Edit([Bind(Include = "Id,GovernorateName,CountryId")] Governorate governorate)
 {
     if (ModelState.IsValid)
     {
         db.Entry(governorate).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CountryId = new SelectList(db.Countries, "Id", "CountryName", governorate.CountryId);
     return(View(governorate));
 }
        public ActionResult Create([Bind(Include = "ID,Name")] Governorate governorate)
        {
            if (ModelState.IsValid)
            {
                db.Governorates.Add(governorate);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(governorate));
        }
        public ActionResult Create([Bind(Include = "Id,GovernorateName,CountryId")] Governorate governorate)
        {
            if (ModelState.IsValid)
            {
                db.Governorates.Add(governorate);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CountryId = new SelectList(db.Countries, "Id", "CountryName", governorate.CountryId);
            return(View(governorate));
        }
        // GET: Governorates/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Governorate governorate = db.Governorates.Find(id);

            if (governorate == null)
            {
                return(HttpNotFound());
            }
            return(View(governorate));
        }
        // GET: Governorates/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Governorate governorate = db.Governorates.Find(id);

            if (governorate == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CountryId = new SelectList(db.Countries, "Id", "CountryName", governorate.CountryId);
            return(View(governorate));
        }
 public ActionResult Create(GovernorateVM governorateVM)
 {
     try
     {
         Governorate governorate = new Governorate
         {
             ID   = governorateVM.ID,
             Name = governorateVM.Name
         };
         GovernorateService.InsertGovernorate(governorate);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        public ActionResult Create([Bind(Include = "GovernorateId,Governorate1")] Governorate governorate)
        {
            if (ModelState.IsValid)
            {
                // get last record
                int max = db.Governorates.Max(p => p.GovernorateId);
                // add 1 to get new record id
                governorate.GovernorateId = (short)(max + 1);
                if (governorate.Governorate1 != "")
                {
                    db.Governorates.Add(governorate);
                    db.SaveChanges();
                }
                return(RedirectToAction("Index"));
            }

            return(View(governorate));
        }
Пример #17
0
        public static GovernorateVM MapToGovernorateVM(this Governorate governorate)
        {
            GovernorateVM governorateVM = new GovernorateVM()
            {
                Id               = governorate.Id,
                DFIndicatorId    = governorate.DFIndicatorId,
                DFYearId         = governorate.DFYearId,
                DFGovernorateId  = governorate.DFGovernorateId,
                Unit             = governorate.Unit,
                DomesticWorkers  = governorate.DomesticWorkers,
                CustomFees       = governorate.CustomFees,
                Communication    = governorate.Communication,
                BusinessServices = governorate.BusinessServices,
                Agriculture      = governorate.Agriculture,
                AccommodationandFoodServiceActivities = governorate.AccommodationandFoodServiceActivities,
                Construction             = governorate.Construction,
                CrudePetroleumExtraction = governorate.CrudePetroleumExtraction,
                Education             = governorate.Education,
                ElectricityandGas     = governorate.ElectricityandGas,
                FinancialCorporations = governorate.FinancialCorporations,
                GeneralGovernment     = governorate.GeneralGovernment,
                Information           = governorate.Information,
                Health    = governorate.Health,
                isDeleted = governorate.isDeleted,
                ManufacturingIndustries  = governorate.ManufacturingIndustries,
                NonFinancialCorporations = governorate.NonFinancialCorporations,
                NonProfitInstitutionsServingHouseholdSector = governorate.NonProfitInstitutionsServingHouseholdSector,
                OtherExtractions            = governorate.OtherExtractions,
                OtherServices               = governorate.OtherServices,
                PetroleumRefinement         = governorate.PetroleumRefinement,
                RealEstateOwnership         = governorate.RealEstateOwnership,
                Sewerage                    = governorate.Sewerage,
                TotalGDPEgyptWithCustomFees = governorate.TotalGDPEgyptWithCustomFees,
                TotalGovernorateGDP         = governorate.TotalGovernorateGDP,
                Water = governorate.Water,
                TransportationandStorage = governorate.TransportationandStorage,
                WasteRecycling           = governorate.WasteRecycling,
                WholesaleandRetailTrade  = governorate.WholesaleandRetailTrade,
                GovernorateId            = governorate.Id,
            };

            return(governorateVM);
        }
        public bool SoftDelete(int id)
        {
            try
            {
                Governorate model = _db.Governorates.FirstOrDefault(x => x.Id == id);
                if (model != null)
                {
                    model.isDeleted = true;

                    Update(model);

                    return(true);
                }
                return(false);
            }
            catch
            {
                return(false);
            }
        }
 public void Update(Governorate governorate)
 {
     _db.Governorates.Attach(governorate);
     _db.Entry(governorate).State = EntityState.Modified;
     _db.SaveChanges();
 }
Пример #20
0
 public void AddGovernorate(Governorate c)
 {
     _context.Set <Governorate>().Add(c);
 }
Пример #21
0
 public void Delete(Governorate c)
 {
     _context.Set <Governorate>().Remove(c);
 }
Пример #22
0
 public void UpdateGovernorate(Governorate c)
 {
     _context.Entry(c).State = EntityState.Modified;
 }
Пример #23
0
        private ClusterMapViewModel GetClusters(string Govt_ID, string District_ID, string Sector_ID, string Field_ID, string Product_ID, string ClusterNature_ID, string ClusterType_ID, string IncomeLevel_ID, string ExportFlag_ID, string ProductSeason_ID)
        {
            var clusters = (from d in db.Clusters orderby d.Govt_ID, d.Cluster_Name ascending select d).ToList();

            if (Govt_ID != "")
            {
                clusters = (from d in clusters orderby d.Govt_ID, d.Cluster_Name ascending where d.Govt_ID == Govt_ID select d).ToList();
            }
            if (District_ID != "0" && District_ID != "")
            {
                clusters = (from d in clusters orderby d.Govt_ID, d.Cluster_Name ascending where d.District_ID == District_ID select d).ToList();
            }
            if (Sector_ID != "")
            {
                clusters = (from d in clusters orderby d.Govt_ID, d.Cluster_Name ascending where d.Sector_ID == Sector_ID select d).ToList();
            }
            if (Field_ID != "0" && Field_ID != "")
            {
                clusters = (from d in clusters orderby d.Govt_ID, d.Cluster_Name ascending where d.Field_ID == Field_ID select d).ToList();
            }
            if (Product_ID != "0" && Product_ID != "")
            {
                clusters = (from d in clusters orderby d.Govt_ID, d.Cluster_Name ascending where d.Product_ID == Product_ID select d).ToList();
            }
            if (ClusterNature_ID != null && ClusterNature_ID != "")
            {
                clusters = (from d in clusters orderby d.Govt_ID, d.Cluster_Name ascending where d.ClusterNature_ID == ClusterNature_ID select d).ToList();
            }
            if (ClusterType_ID != null && ClusterType_ID != "")
            {
                clusters = (from d in clusters orderby d.Govt_ID, d.Cluster_Name ascending where d.ClusterType_ID == ClusterType_ID select d).ToList();
            }
            if (IncomeLevel_ID != null && IncomeLevel_ID != "")
            {
                clusters = (from d in clusters orderby d.Govt_ID, d.Cluster_Name ascending where d.IncomeLevel_ID == IncomeLevel_ID select d).ToList();
            }
            if (ExportFlag_ID != null && ExportFlag_ID != "")
            {
                clusters = (from d in clusters orderby d.Govt_ID, d.Cluster_Name ascending where d.ExportFlag_ID == ExportFlag_ID select d).ToList();
            }
            if (ProductSeason_ID != null && ProductSeason_ID != "")
            {
                clusters = (from d in clusters orderby d.Govt_ID, d.Cluster_Name ascending where d.ProductSeason_ID == ProductSeason_ID select d).ToList();
            }

            //List<ClusterMapViewModel> listClusterMapViewModel = new List<ClusterMapViewModel>();
            List <GovtData>    listGovtData    = new List <GovtData>();
            List <ClusterData> listClusterData = new List <ClusterData>();

            for (Int16 govtID = 1; govtID <= 27; govtID++)
            {
                GovtData govtData = new GovtData();
                govtData.Cluster_Num = 0;
                govtData.ShopNumMin  = 0;

                govtData.EmpNumMin = 0;

                govtData.ExportNum = 0;

                Governorate govt = db.Governorates.Find(govtID.ToString("00"));
                govtData.Govt_ID   = govt.Govt_ID;
                govtData.Govt_Name = govt.Govt_Name;
                govtData.Govt_Lat  = govt.Govt_Lat;
                govtData.Govt_Long = govt.Govt_Long;

                listGovtData.Add(govtData);
            }

            foreach (Cluster c in clusters)
            {
                var govtIndex   = Convert.ToInt16(c.Govt_ID) - 1;
                var sectorIndex = Convert.ToInt16(c.Sector_ID) - 1;

                ClusterData clusterData = new ClusterData();
                listGovtData[govtIndex].Cluster_Num++;
                listGovtData[govtIndex].ShopNumMin = listGovtData[govtIndex].ShopNumMin + c.Cluster_ShopNumMin;

                listGovtData[govtIndex].EmpNumMin = listGovtData[govtIndex].EmpNumMin + c.Cluster_EmpNumMin;

                if (c.ExportFlag_ID == "01")
                {
                    listGovtData[govtIndex].ExportNum++;
                }

                clusterData.Cluster_ID   = c.Cluster_ID;
                clusterData.Cluster_Name = c.Cluster_Name;
                clusterData.Cluster_Lat  = c.Cluster_Lat;
                clusterData.Cluster_Long = c.Cluster_Long;
                clusterData.Sector_ID    = Convert.ToInt16(c.Sector_ID);
                clusterData.Govt_ID      = Convert.ToInt16(c.Govt_ID);
                clusterData.Govt_Name    = c.Governorate.Govt_Name;

                if (c.District != null)
                {
                    clusterData.District_Name = c.District.District_Name;
                }
                else
                {
                    clusterData.District_Name = "";
                }

                if (c.Village != null)
                {
                    clusterData.Village_Name = c.Village.Village_Name;
                }
                else
                {
                    clusterData.Village_Name = "";
                }

                clusterData.Cluster_ProcessImage = c.Cluster_ProcessImage;
                clusterData.Cluster_ProductImage = c.Cluster_ProductImage;
                clusterData.Cluster_Info1        = c.Governorate.Govt_Name;

                if (c.District != null)
                {
                    clusterData.Cluster_Info1 = clusterData.Cluster_Info1 + " - " + c.District.District_Name;
                }

                if (c.Village != null)
                {
                    clusterData.Cluster_Info1 = clusterData.Cluster_Info1 + " - " + c.Village.Village_Name;
                }


                clusterData.Cluster_Info2 = " متوسط عدد العاملين " + ":&nbsp";
                if (c.Cluster_EmpNumMin != 0)
                {
                    clusterData.Cluster_Info2 = clusterData.Cluster_Info2 + c.Cluster_EmpNumMin;
                }



                clusterData.Cluster_Info3 = " متوسط عدد الوحدات الانتاجية " + ":&nbsp";
                if (c.Cluster_ShopNumMin != 0)
                {
                    clusterData.Cluster_Info3 = clusterData.Cluster_Info3 + c.Cluster_ShopNumMin;
                }



                clusterData.Cluster_Info4 = "نسبة التصدير: ";
                if (c.ExportVolume != null)
                {
                    clusterData.Cluster_Info4 = clusterData.Cluster_Info4 + c.ExportVolume;
                }

                clusterData.Cluster_Info5 = "المنتجات: ";
                if (c.Products != null)
                {
                    clusterData.Cluster_Info5 = clusterData.Cluster_Info5 + c.Products;
                }
                listClusterData.Add(clusterData);
            }

            ClusterMapViewModel clusterMapViewModel = new ClusterMapViewModel();

            clusterMapViewModel.GovtData    = listGovtData;
            clusterMapViewModel.ClusterData = listClusterData;


            return(clusterMapViewModel);
        }
 public void Add(Governorate governorate)
 {
     _db.Governorates.Add(governorate);
     _db.SaveChanges();
 }