protected void bKaydetYeniYapimciEkle_Click(object sender, EventArgs e)
 {
     try
     {
         if (string.IsNullOrWhiteSpace(tbYeniYapimciEkleAd.Text))
         {
             lMesaj.Text = "Yapımcı Adı girilmelidir!";
             return;
         }
         if (ddlYapimciEkleUlke.SelectedValue == "")
         {
             lMesaj.Text = "Ulke seçilmelidir.";
             return;
         }
         YapimciModel model = new YapimciModel()
         {
             Adi    = tbYeniYapimciEkleAd.Text,
             UlkeId = Convert.ToInt32(ddlYapimciEkleUlke.SelectedValue)
         };
         _yapimciService.Add(model);
         FillGridYapimci();
     }
     catch (Exception exc)
     {
         throw exc;
     }
 }
        public void Update(YapimciModel model)
        {
            var entity = _db.Set <Yapimci>().Find(model.Id);

            entity.Adi = model.Adi.Trim();
            _db.Set <Yapimci>().Update(entity);
            _db.SaveChanges();
        }
示例#3
0
 //[HttpPost] // aksiyon adı aynı olduğu için yazılmasına gerek yoktur
 public IActionResult Post([FromBody] YapimciModel model)
 {
     if (ModelState.IsValid)
     {
         _yapimciService.Add(model);
         return(Ok(model));
     }
     return(BadRequest(ModelState));
 }
        public void Guncelle(YapimciModel model)
        {
            Yapimci yapimci = _db.Yapimcilar.Find(model.Id);

            yapimci.Adi    = model.Adi;
            yapimci.UlkeId = model.UlkeId;

            _db.Entry(yapimci).State = System.Data.Entity.EntityState.Modified;
            _db.SaveChanges();
        }
示例#5
0
 //[HttpPut] // aksiyon adı aynı olduğu için yazılmasına gerek yoktur
 public IActionResult Put([FromODataUri] int key, [FromBody] YapimciModel model)
 {
     if (ModelState.IsValid)
     {
         model.Id = key;
         _yapimciService.Update(model);
         return(Ok(model));
     }
     return(BadRequest(ModelState));
 }
        public void Add(YapimciModel model)
        {
            Yapimci entity = new Yapimci()
            {
                Adi    = model.Adi,
                UlkeId = model.UlkeId
            };

            _db.Yapimcilar.Add(entity);
            _db.SaveChanges();
        }
        public void Add(YapimciModel model)
        {
            var entity = new Yapimci()
            {
                Adi = model.Adi.Trim()
            };

            _db.Set <Yapimci>().Add(entity);
            _db.SaveChanges();
            model.Id = entity.Id;
        }
        private void FillUlkeDetails()
        {
            if (gvYapimcilar.SelectedIndex == -1)
            {
                lMesaj.Text = "Kayıt seçiniz.";
                return;
            }
            int          id    = Convert.ToInt32(gvYapimcilar.SelectedRow.Cells[1].Text);
            YapimciModel model = _yapimciService.GetQuery().SingleOrDefault(yapimci => yapimci.Id == id);

            tbYeniGuncelle.Text           = model.Adi;
            ddlYeniGuncelle.SelectedValue = "";
            ddlYeniGuncelle.SelectedValue = model.UlkeId.ToString();
        }
        public async Task <YapimciModel> UpdateYapimciAsync(YapimciModel yapimci)
        {
            YapimciModel yapimciSonuc       = null;
            string       yapimciJson        = JsonSerializer.Serialize(yapimci); // servise gönderilen JSON
            HttpContent  yapimciHttpContent = new StringContent(yapimciJson, Encoding.UTF8, "application/json");
            var          result             = await _httpClient.PutAsync(_yapimciApiUrl + "/" + yapimci.Id, yapimciHttpContent);

            if (result.IsSuccessStatusCode)
            {
                yapimciJson = await result.Content.ReadAsStringAsync(); // güncelleme işleminden sonra servisten dönen JSON

                yapimciSonuc = JsonSerializer.Deserialize <YapimciModel>(yapimciJson);
            }
            return(yapimciSonuc);
        }
 protected void YapimciDetay_Click(object sender, EventArgs e)
 {
     try
     {
         if (gvYapimcilar.SelectedIndex == -1)
         {
             lMesaj.Text = "Kayıt seçiniz!";
             return;
         }
         int          id    = Convert.ToInt32(gvYapimcilar.SelectedRow.Cells[1].Text);
         YapimciModel model = _yapimciService.GetQuery().SingleOrDefault(yapimci => yapimci.Id == id);
         lAdiYapimciDetay.Text      = model.Adi;
         lUlkeYapimciDetay.Text     = model.UlkeAdi;
         pYapimciDetay.Visible      = true;
         pYapimciGuncelle.Visible   = false;
         pYeniYapimciEkleme.Visible = false;
     }
     catch (Exception exc)
     {
         throw exc;
     }
 }
        protected void bKaydetGuncelle_Click(object sender, EventArgs e)
        {
            try
            {
                if (gvYapimcilar.SelectedIndex == -1)
                {
                    lMesaj.Text = " Kayıt seçiniz!";
                    return;
                }
                if (string.IsNullOrWhiteSpace(tbYeniGuncelle.Text))
                {
                    lMesaj.Text = "Adı girilmelidir.";
                    return;
                }
                if (ddlYeniGuncelle.SelectedValue == "")
                {
                    lMesaj.Text = "Yapımcı seçilmelidir.";
                    return;
                }

                YapimciModel model = new YapimciModel()
                {
                    Id     = Convert.ToInt32(gvYapimcilar.SelectedRow.Cells[1].Text),
                    Adi    = tbYeniGuncelle.Text,
                    UlkeId = Convert.ToInt32(ddlYeniGuncelle.SelectedValue)
                };

                _yapimciService.Guncelle(model);
                FillGridYapimci();
                pYapimciGuncelle.Visible = false;
                lMesaj.Text = "Yapimci kaydedildi!";
            }
            catch (FormatException exc)
            {
            }
        }