コード例 #1
0
 public static bool Ekle(VMKampanya Data)
 {
     using (MMDB db = new MMDB())
     {
         try
         {
             bool bul = db.Kampanya.Any(p => p.KampanyaAdi == Data.KampanyaAdi.Trim());
             if (bul != true)
             {
                 db.Kampanya.Add(new Kampanya()
                 {
                     KampanyaAdi  = Data.KampanyaAdi.Trim(),
                     IndirimOrani = Data.IndirimOrani
                 });
                 db.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch
         {
             return(false);
         }
     }
 }
コード例 #2
0
        public IHttpActionResult Delete(VMKampanya data) //Kampanya Sildik
        {
            bool sonuc = KampanyaRepo.Sil(data);

            if (sonuc != true)
            {
                return(NotFound());
            }
            else
            {
                return(Ok());
            }
        }
コード例 #3
0
 public static bool Sil(VMKampanya Data)
 {
     using (MMDB db = new MMDB())
     {
         try
         {
             var bul = db.Kampanya.FirstOrDefault(p => p.KampanyaID == Data.KampanyaID);
             db.Kampanya.Remove(bul);
             db.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
コード例 #4
0
 public static bool Guncelle(VMKampanya Data)
 {
     using (MMDB db = new MMDB())
     {
         try
         {
             var bul = db.Kampanya.FirstOrDefault(p => p.KampanyaID == Data.KampanyaID);
             bul.KampanyaAdi  = Data.KampanyaAdi.Trim();
             bul.IndirimOrani = Data.IndirimOrani;
             db.SaveChanges();
             return(true);
         }
         catch
         {
             return(false);
         }
     }
 }
コード例 #5
0
 public IHttpActionResult Put(VMKampanya data) //Kampanya Duzenledik
 {
     if (ModelState.IsValid == false)
     {
         return(BadRequest(ModelState));
     }
     else
     {
         bool sonuc = KampanyaRepo.Guncelle(data);
         if (sonuc != true)
         {
             return(NotFound());
         }
         else
         {
             return(Ok());
         }
     }
 }
コード例 #6
0
 public IHttpActionResult Post(VMKampanya data) //Kampanya Kaydettik
 {
     if (ModelState.IsValid)
     {
         bool durum = KampanyaRepo.Ekle(data);
         if (durum == true)
         {
             return(CreatedAtRoute("DefaultApi", new { id = data.KampanyaID }, durum));
         }
         else
         {
             return(BadRequest(ModelState));
         }
     }
     else
     {
         return(BadRequest(ModelState));
     }
 }