public ActionResult InsertMahalle(Mahalle mahalle) { dbContext.Mahalleler.Add(mahalle); dbContext.SaveChanges(); return(View()); }
public async Task <IHttpActionResult> PutMahalle(int id, Mahalle mahalle) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != mahalle.Id) { return(BadRequest()); } db.Entry(mahalle).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MahalleExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult UpdateMahalle(Mahalle model) { Mahalle mahalle = dbContext.Mahalleler.Where(x => x.Id == model.Id).FirstOrDefault(); if (mahalle != null) { mahalle.IlceId = model.IlceId; mahalle.MahalleAdi = model.MahalleAdi; //Burası önemli buradaki ID durumunu çöz mahalle.PostaKodu = model.PostaKodu; int sonuc = dbContext.SaveChanges(); if (sonuc > 0) { ViewBag.Result = "Güncelleme işlemi başarılı."; ViewBag.Status = "success"; } else { ViewBag.Result = "Güncelleme işlemi başarısız."; ViewBag.Status = "danger"; } } return(View(mahalle)); }
public ActionResult UpdateMahalle(int?id) { Mahalle mahalle = null; if (id != null) { mahalle = dbContext.Mahalleler.Where(x => x.Id == id).FirstOrDefault(); } return(View(mahalle)); }
public IActionResult Update(Mahalle mahalle) { var result = _mahalleService.Update(mahalle); if (result.Success) { return(Ok(result.Message)); } return(BadRequest(result.Message)); }
public async Task <IHttpActionResult> GetMahalle(int id) { Mahalle mahalle = await db.Mahalles.FindAsync(id); if (mahalle == null) { return(NotFound()); } return(Ok(mahalle)); }
public async Task <Mahalle> Update(Mahalle entity) { using (var _DefaultDbContext = new DefaultDbContext()) { _DefaultDbContext.tblMahalle.Update(entity); entity.AktifMi = true; await _DefaultDbContext.SaveChangesAsync(); return(entity); } }
public async Task <IActionResult> Add(Mahalle entity) { try { if (ModelState.IsValid) { var eklenenMahalle = await _mahalle.Add(entity); await _log.Add(new Log() { DurumId = 1, IslemTipId = 3, Aciklama = entity.Ad + " Mahallesi Eklendi", KullaniciId = Convert.ToInt32(Request.Headers["current-user-id"]), KullaniciAdi = Request.Headers["current-user-name"], Tarih = DateTime.Now, IP = Request.Headers["ip-address"] }); return(CreatedAtAction("GetById", new { id = eklenenMahalle.Id }, eklenenMahalle)); } else { await _log.Add(new Log() { DurumId = 2, IslemTipId = 3, Aciklama = entity.Ad + " Mahallesi Eklenemedi", KullaniciId = Convert.ToInt32(Request.Headers["current-user-id"]), KullaniciAdi = Request.Headers["current-user-name"], Tarih = DateTime.Now, IP = Request.Headers["ip-address"] }); return(BadRequest(ModelState)); } } catch (System.Exception) { await _log.Add(new Log() { DurumId = 2, IslemTipId = 3, Aciklama = "Mahalle Servisinde Ekleme Hatası Oluştu!", KullaniciId = Convert.ToInt32(Request.Headers["current-user-id"]), KullaniciAdi = Request.Headers["current-user-name"], Tarih = DateTime.Now, IP = Request.Headers["ip-address"] }); return(BadRequest(ModelState)); } }
public async Task <IHttpActionResult> PostMahalle(Mahalle mahalle) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Mahalles.Add(mahalle); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = mahalle.Id }, mahalle)); }
public async Task <Mahalle> GetById(int id) { using (var _DefaultDbContext = new DefaultDbContext()) { Mahalle model = await _DefaultDbContext.tblMahalle.Include(m => m.Ilce).ThenInclude(m => m.Il).FirstOrDefaultAsync(m => m.Id == id); if (model == null) { throw new System.NotImplementedException(); } return(model); } }
public IActionResult Add(Mahalle mahalle) { var mKodu = _mahalleService.GetList().Data.Count; mahalle.MahalleKodu = mKodu + 1; var result = _mahalleService.Add(mahalle); if (result.Success) { return(Ok(result.Message)); } return(BadRequest(result.Message)); }
public async Task <IActionResult> Update(Mahalle entity) { try { if (await _mahalle.GetById(entity.Id) != null) { await _log.Add(new Log() { DurumId = 1, IslemTipId = 5, Aciklama = entity.Ad + " Mahallesi Düzenlendi", KullaniciId = Convert.ToInt32(Request.Headers["current-user-id"]), KullaniciAdi = Request.Headers["current-user-name"], Tarih = DateTime.Now, IP = Request.Headers["ip-address"] }); return(Ok(_mahalle.Update(entity))); } else { await _log.Add(new Log() { DurumId = 2, IslemTipId = 5, Aciklama = entity.Ad + " Mahallesi Düzenlenemedi", KullaniciId = Convert.ToInt32(Request.Headers["current-user-id"]), KullaniciAdi = Request.Headers["current-user-name"], Tarih = DateTime.Now, IP = Request.Headers["ip-address"] }); return(NotFound()); } } catch (System.Exception) { await _log.Add(new Log() { DurumId = 2, IslemTipId = 5, Aciklama = "Mahalle Servisinde Düzenleme Hatası Oluştu!", KullaniciId = Convert.ToInt32(Request.Headers["current-user-id"]), KullaniciAdi = Request.Headers["current-user-name"], Tarih = DateTime.Now, IP = Request.Headers["ip-address"] }); return(NotFound()); } }
public async Task <IHttpActionResult> DeleteMahalle(int id) { Mahalle mahalle = await db.Mahalles.FindAsync(id); if (mahalle == null) { return(NotFound()); } db.Mahalles.Remove(mahalle); await db.SaveChangesAsync(); return(Ok(mahalle)); }
public JsonResult InsertDistrict(Mahalle mahalle) { string query = "INSERT INTO mahalle(mahalleAdı,koordinat) VALUES(@mahalleAdı,@koordinat)"; // query += "SELECT SCOPE_IDENTITY()"; string connectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString; using (MySqlConnection con = new MySqlConnection(connectionString)) { using (MySqlCommand cmd = new MySqlCommand(query)) { cmd.Parameters.AddWithValue("@mahalleAdı", mahalle.mahalleAdı); cmd.Parameters.AddWithValue("@koordinat", mahalle.koordinat.Trim()); cmd.Connection = con; con.Open(); mahalle.mahalleKodu = Convert.ToInt32(cmd.ExecuteScalar()); //MessageBox.Show(mahalle.mahalleKodu.ToString()); con.Close(); } } return(Json(mahalle)); }
public JsonResult UpdateDistrict(Mahalle mahalle) { string query = "UPDATE mahalle SET mahalleAdı=@mahalleAdı, koordinat=@koordinat WHERE mahalleKodu=@mahalleKodu"; string connectionString = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString; using (MySqlConnection con = new MySqlConnection(connectionString)) { using (MySqlCommand cmd = new MySqlCommand(query)) { cmd.Parameters.AddWithValue("@mahalleKodu", mahalle.mahalleKodu); cmd.Parameters.AddWithValue("@mahalleAdı", mahalle.mahalleAdı); cmd.Parameters.AddWithValue("@koordinat", mahalle.koordinat); cmd.Connection = con; con.Open(); //mahalle.mahalleKodu = Convert.ToInt32(cmd.ExecuteScalar()); cmd.ExecuteNonQuery(); con.Close(); } } return(Json(mahalle)); }
public JsonResult SavePointMahalle(Mahalle mah, string koordinat, string mahadi) { int sayac = 0; HARİTAEntities1 db = new HARİTAEntities1(); foreach (var item in db.Mahalle) { if (item.KOORDINAT == koordinat) { sayac = 1; } } if (sayac == 0) { mah.MAH_ADI = mahadi; mah.KOORDINAT = koordinat; db.Mahalle.Add(mah); db.SaveChanges(); } return(Json("")); }
private static void mahalleler() { var h = Mitab.mitab_c_open(@"C:\Users\Hkn\Documents\visual studio 2015\Projects\BasarMapTry\BasarMapTry\data\KOYMAHALLE.TAB"); var c = new MitabColumns(h); var featureId = Mitab.mitab_c_next_feature_id(h, -1); var client = new MongoClient(); var database = client.GetDatabase("test"); var collection = database.GetCollection <Mahalle>("Mahalleler"); collection.Indexes.CreateOneAsync("{ \"Geo\" : \"2dsphere\"}"); var s = 0; var hata = 0; while (featureId != -1) { var feature = Mitab.mitab_c_read_feature(h, featureId); var polygonCount = Mitab.mitab_c_get_parts(feature); var ustidariId = Mitab.mitab_c_get_field_as_string_csharp(feature, c.GetColumn("USTIDARIID").index); var ilAdi = Mitab.mitab_c_get_field_as_string_csharp(feature, c.GetColumn("ILADI").index); var idariId = Mitab.mitab_c_get_field_as_string_csharp(feature, c.GetColumn("IDARIID").index); var ilceAdi = Mitab.mitab_c_get_field_as_string_csharp(feature, c.GetColumn("ILCEADI").index); var ilKod = Mitab.mitab_c_get_field_as_string_csharp(feature, c.GetColumn("ILKOD").index); var adi = Mitab.mitab_c_get_field_as_string_csharp(feature, c.GetColumn("ADI").index); var adiAdr = Mitab.mitab_c_get_field_as_string_csharp(feature, c.GetColumn("ADIADR").index); var tip = Mitab.mitab_c_get_field_as_string_csharp(feature, c.GetColumn("TIP").index); var tipKod = Mitab.mitab_c_get_field_as_string_csharp(feature, c.GetColumn("TIPKOD").index); var postaKodu = Mitab.mitab_c_get_field_as_string_csharp(feature, c.GetColumn("POSTAKODU").index); var nufus = Mitab.mitab_c_get_field_as_string_csharp(feature, c.GetColumn("NUFUS").index); var polygons = new BsonArray(); var type = ""; for (var i = 0; i < polygonCount; i++) { var outerArr = new BsonArray(); var polygon = new BsonArray(); var vertexCount = Mitab.mitab_c_get_vertex_count(feature, i); for (var j = 0; j < vertexCount; j++) { var coordinates = new BsonArray(); var lng = Mitab.mitab_c_get_vertex_x(feature, i, j); var lat = Mitab.mitab_c_get_vertex_y(feature, i, j); coordinates.Add(lng); coordinates.Add(lat); polygon.Add(coordinates); } if (polygonCount > 1) { outerArr.Add(polygon); polygons.Add(outerArr); type = "MultiPolygon"; } else { polygons.Add(polygon); type = "Polygon"; } } var mahalle = new Mahalle { UstIdariId = Convert.ToInt32(ustidariId), IlAdi = ilAdi, IdariId = Convert.ToInt32(idariId), IlceAdi = ilceAdi, IlKod = Convert.ToInt32(ilKod), Adi = adi, AdiAdr = adiAdr, Tip = tip, TipKod = Convert.ToInt32(tipKod), PostaKodu = Convert.ToInt32(postaKodu), Nufus = Convert.ToInt32(nufus), Geo = new GeoPointBson() { type = type, coordinates = polygons } }; try { collection.InsertOneAsync(mahalle); s++; Console.WriteLine("eklenen mahalle :" + s); } catch { hata++; Console.WriteLine("hata"); } Mitab.mitab_c_destroy_feature(feature); featureId = Mitab.mitab_c_next_feature_id(h, featureId); } }
public IResult Update(Mahalle mahalle) { _mahalleDal.Add(mahalle); return(new SuccessResult(Messages.MahalleUpdated)); }
public IResult Delete(Mahalle mahalle) { _mahalleDal.Delete(mahalle); return(new SuccessResult(Messages.MahalleDeleted)); }
public IResult Add(Mahalle mahalle) { _mahalleDal.Add(mahalle); return(new SuccessResult(Messages.MahalleAdded)); }