public IActionResult Put(Personel personel) { if (personel.Id <= 0) { return(BadRequest("Id iblgisi sıfırdan büyük olmalıdır!")); } Personel personelPUT = ListPersonleList.Where(w => w.Id == personel.Id).FirstOrDefault(); if (personelPUT == null) { return(NotFound("Bu id bilgisiyle personel bulunamadı!")); } if (string.IsNullOrEmpty(personel.Ad) || string.IsNullOrEmpty(personel.Soyad)) { return(BadRequest("Personele ait ad / soyad bilgisi boş geçilemez!")); } int index = ListPersonleList.IndexOf(personelPUT); ListPersonleList.Remove(personelPUT); ListPersonleList.Insert(index, personel); return(Ok("Başarıyla güncellendi..")); }
public IActionResult Delete(int id) { if (id <= 0) { return(NotFound("Id iblgisi sıfırdan büyük olmalıdır!")); } Personel personelDelete = ListPersonleList.Where(w => w.Id == id).FirstOrDefault(); if (personelDelete == null) { return(NotFound("Bu id bilgisiyle personel bulunamadı!")); } ListPersonleList.Remove(personelDelete); return(Ok("Başarıyla silindi")); }