public IHttpActionResult PutSportProgram(int id, SportProgram sportProgram)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != sportProgram.ID)
            {
                return(BadRequest());
            }

            db.Entry(sportProgram).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SportProgramExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult GetSportProgram(int id)
        {
            SportProgram sportProgram = db.SportProgram.Find(id);

            if (sportProgram == null)
            {
                return(NotFound());
            }

            return(Ok(sportProgram));
        }
        public IHttpActionResult PostSportProgram(SportProgram sportProgram)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.SportProgram.Add(sportProgram);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = sportProgram.ID }, sportProgram));
        }
        public IHttpActionResult DeleteSportProgram(int id)
        {
            SportProgram sportProgram = db.SportProgram.Find(id);

            if (sportProgram == null)
            {
                return(NotFound());
            }

            db.SportProgram.Remove(sportProgram);
            db.SaveChanges();

            return(Ok(sportProgram));
        }
예제 #5
0
        public ActionResult SportDelete(int sportPieceID)
        {
            Xamarin_KURSATCAKALEntities DB = new Xamarin_KURSATCAKALEntities();
            SportProgram silinecek         = DB.SportProgram.Where(x => x.ID == sportPieceID).First();

            try
            {
                DB.SportProgram.Remove(silinecek);
                DB.SaveChanges();
                TempData["DeleteSuccess"] = "Silme İşlemi Başarılı";
            }
            catch (Exception)
            {
                TempData["SportPieceDeleteException"] = "Bu parça başka bir tablo tarafından kullanılıyor.";
            }
            return(RedirectToAction("SportList"));
        }
예제 #6
0
        public ActionResult SportAddUpdate(int?guncelleID, int dayID, int imageID, int actID, int userID, string inputRepeatPercentage)
        {
            Xamarin_KURSATCAKALEntities DB = new Xamarin_KURSATCAKALEntities();

            try
            {
                SportProgram eklenecekParca = new SportProgram
                {
                    ActID            = actID,
                    DayID            = dayID,
                    ImageID          = imageID,
                    RepeatPercantage = inputRepeatPercentage,
                    PersonID         = userID,
                };
                DB.SportProgram.Add(eklenecekParca);
                DB.SaveChanges();
                TempData["AdditionSuccess"] = "Ekleme İşlemi Başarılı";
            }
            catch (Exception)
            {
                TempData["SportAddUpdateException"] = "Lütfen değer formatlarını doğru giriniz.";
            }
            return(RedirectToAction("SportList"));
        }