public ActionResult SetScoreIntervals(ScoreSetting scoreSetting)
 {
     if (InputOrder(scoreSetting))
     {
         try
         {
             using (var db = new CarpmaContext())
             {
                 var currentSetting = db.ScoreSettings.First();
                 currentSetting.Wood = scoreSetting.Wood;
                 currentSetting.Copper = scoreSetting.Copper;
                 currentSetting.Silver = scoreSetting.Silver;
                 currentSetting.Gold = scoreSetting.Gold;
                 db.SaveChanges();
                 ViewBag.ValidationStatus = "success";
                 return View("SetScoreIntervals");
             }
         }
         catch (Exception)
         {
             ViewBag.ValidationStatus = "error";
             return View("SetScoreIntervals");
         }                
     }
     else
     {
         ViewBag.ValidationStatus = "failure";
         return View("SetScoreIntervals");
     }            
 }
 /// <summary>
 /// You make a get request to this method with an integer(1:Wood, 2:Copper, 3:Silver, 4:Gold), it creates a question in the database using the id as the max value(inclusive) for the numbers and returns that question. Parameter name is "id" because I am lazy.
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 // GET api/values/5
 public IHttpActionResult Get(int id)
 {
     try
     {
         using (var db = new CarpmaContext())
         {
             int maxValue = GetMaxValue(id, db);
             var rnd = new Random();
             int number1 = rnd.Next(2, maxValue);
             int number2 = rnd.Next(2, maxValue);
             var questionToCreateAndSend = new Question
             {
                 CreateDate = DateTime.Now,
                 IsChecked = false,
                 Max = maxValue,
                 Number1 = number1,
                 Number2 = number2,
                 Result = number1 * number2
             };
             db.Questions.Add(questionToCreateAndSend);
             db.SaveChanges();
             return Created<Question>("", questionToCreateAndSend);
         }
     }
     catch (Exception e)
     {
         return InternalServerError(e);
     }
 }
 public ActionResult ResetScore()
 {
     try
     {
         using (var db = new CarpmaContext())
         {
             var score = db.Scores.First();
             score.Wood = 0;
             score.Copper = 0;
             score.Silver = 0;
             score.Gold = 0;
             db.SaveChanges();
             ViewBag.ResetStatus = "success";
             return View("ResetScores");
         }
     }
     catch (Exception)
     {
         ViewBag.ResetStatus = "error";
         return View("ResetScores");
     }
 }
        /// <summary>
        /// Send your answered question in the body. Use question id as url parameter. It will return the updated score. Method is POST instead of PUT because of Unity3d's WWW class limitations.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        // POST api/values/5
        public IHttpActionResult Post(int id, [FromBody]Question value)
        {
            Score score;
            ScoreSetting scoreSetting;
            Question questionToUpdate;
            try
            {
                using (var db = new CarpmaContext())
                {
                    scoreSetting = db.ScoreSettings.First();
                    score = db.Scores.First();
                    questionToUpdate = db.Questions.First(p => p.Id == id);
                    questionToUpdate.SolveDate = value.SolveDate;
                    questionToUpdate.SolveSeconds = value.SolveSeconds;

                    if (value.Max <= scoreSetting.Wood)
                    {
                        score.Wood++;
                    }
                    else if (value.Max <= scoreSetting.Copper)
                    {
                        score.Copper++;
                    }
                    else if (value.Max <= scoreSetting.Silver)
                    {
                        score.Silver++;
                    }
                    else
                    {
                        score.Gold++;
                    }
                    db.SaveChanges();
                }
                return Ok(score);
            }
            catch (Exception e)
            {
                return InternalServerError(e);
            }
        }