Пример #1
0
 // POST: api/Mafia
 public void Post(Game game)
 {
     if (MafiaRepo.IsIdUsed(game.Id))
     {
         MafiaRepo.DeleteGame(game.Id);
     }
     MafiaRepo.AddGame(game);
 }
Пример #2
0
        /// <summary>
        /// This method returns records gotten from DB matching users phone number
        /// </summary>
        /// <param name="tell"></param>
        /// <returns></returns>
        public ReturnMessage UpdateGameUserLastAccess(string tell, GameData.Game game)
        {
            ReturnMessage returnMessage;

            if (tell.Trim() != game.MSISDN.Trim())
            {
                return(returnMessage = new ReturnMessage()
                {
                    Message = "Record Mismatch",
                    Success = false
                });
            }

            try
            {
                //Update Last Access DateTime to Today
                game.LastAccess = DateTime.Today;

                _NGSubscriptionsEntities.Entry(game).State = EntityState.Modified;
                var retVal = _NGSubscriptionsEntities.SaveChanges();
                return(returnMessage = new ReturnMessage()
                {
                    ID = retVal,
                    Message = "Operation Successful",
                    Success = true,
                    Data = game
                });
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SubscriberExists(tell))
                {
                    return(returnMessage = new ReturnMessage()
                    {
                        Message = "Record Not Found",
                        Success = false
                    });
                }
                else
                {
                    throw;
                }
            }
        }
Пример #3
0
 /// <summary>
 /// Method to add new Subscriber to DB
 /// </summary>
 /// <param name="t">User's Telephone Number</param>
 /// <param name="sT">Users selected Subscription Type</param>
 /// <returns></returns>
 public int PostNewSubscriber(GameData.Game game)
 {
     try
     {
         //Check if User already exists in DB
         if (SubscriberExists(game.MSISDN))
         {
             _NGSubscriptionsEntities.Entry(game).State = EntityState.Modified;
         }
         else
         {
             _NGSubscriptionsEntities.Games.Add(game);
         }
         var retVal = _NGSubscriptionsEntities.SaveChanges();
         return(retVal);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #4
0
 public void AddGame(Game game)
 {
     _repo.Add<Game>(game);
 }
Пример #5
0
 private void HandleCardNotPlayable(Game.CardPlayedResult res)
 {
     Debug.Log("Illegal move : " + res);
 }