Esempio n. 1
0
        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.."));
        }
Esempio n. 2
0
        public IActionResult Get(int id)
        {
            if (id <= 0)
            {
                return(BadRequest("Id iblgisi sıfırdan büyük olmalıdır!"));
            }

            Personel personel = ListPersonleList.Where(w => w.Id == id).FirstOrDefault();

            if (personel == null)
            {
                return(NotFound("Bu id bilgisiyle personel bulunamadı!"));
            }

            return(Ok(personel));
        }
Esempio n. 3
0
        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"));
        }
Esempio n. 4
0
        public IActionResult Post(Personel personel)
        {
            if (string.IsNullOrEmpty(personel.Ad) ||
                string.IsNullOrEmpty(personel.Soyad))
            {
                return(BadRequest("Personele ait ad / soyad bilgisi boş geçilemez!"));
            }

            Personel personelExist = ListPersonleList.Where(w => w.Ad.Equals(personel.Ad) && w.Soyad.Equals(personel.Soyad)).FirstOrDefault();

            if (personelExist != null && personelExist.Id > 0)
            {
                return(Conflict("Bu personel sistemde zaten mevcut"));
            }

            personel.Id = ListPersonleList.Max(m => m.Id) + 1;
            ListPersonleList.Add(personel);

            return(Ok("Başarıyla kaydedildi.."));
        }