コード例 #1
0
        public async Task <IActionResult> PutTopic([FromBody] Topic topic)
        {
            if (topic == null)
            {
                return(BadRequest($"Inputed Topic's data is null"));
            }

            _context.Entry(topic).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();

                return(Ok(topic));
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TopicExists(topic.TopicId))
                {
                    return(NotFound($"Could not found Topic with id={topic.TopicId}"));
                }
            }

            return(NoContent());
        }
コード例 #2
0
 public ActionResult Edit([Bind(Include = "TeamId,Name,Flag")] Team team)
 {
     if (ModelState.IsValid)
     {
         db.Entry(team).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(team));
 }
コード例 #3
0
 public ActionResult Edit([Bind(Include = "PredictorId,Email,LastName,FirstName,Points")] Predictor predictor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(predictor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(predictor));
 }
コード例 #4
0
        public ActionResult Edit([Bind(Include = "FixtureId,HomeTeamId,AwayTeamId,GameDate,HomeResult,AwayResult")] Fixture fixture)
        {
            if (ModelState.IsValid)
            {
                db.Entry(fixture).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(fixture));
        }
コード例 #5
0
        public JsonResult ChangeUser(Prediction model)
        {
            // Update model to your db
            var prediction = db.Predictions.Where(p => p.PredictionId == model.PredictionId).SingleOrDefault();

            // input validation
            if (TryUpdateModel(prediction, "",
                        new string[] { "HomeResult", "AwayResult" }))
            {
                try
                {
                    db.Entry(prediction).State = EntityState.Modified;
                    db.SaveChanges();
                }
                catch (RetryLimitExceededException /* dex */)
                {
                    //Log the error (uncomment dex variable name and add a line here to write a log.
                    ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
                }
            }

            string message = "Success";
            return Json(message, JsonRequestBehavior.AllowGet);
        }