Ejemplo n.º 1
0
        public HttpResponseMessage PostNewMatch(MatchContract obj)
        {
            if (obj == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            try
            {
                var    result = obj;
                string token  = MD5Hash(obj.Match.Id.ToString() + obj.Match_User.UserId.ToString());
                obj.Match.Token = token.Substring(0, 5).ToUpper();
                db.Matches.Add(obj.Match);
                db.SaveChanges();
                obj.Match_User.MatchId = obj.Match.Id;
                obj.Match_User.Token   = obj.Match.Token;
                db.Match_Users.Add(obj.Match_User);
                db.SaveChanges();
                return(Request.CreateResponse(HttpStatusCode.OK, result));
            }
            catch (Exception e)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Falha ao criar nova Partida. n/" + e.Message));
            }
        }
Ejemplo n.º 2
0
        public MatchContract GetMatch(int matchId)
        {
            var match = new MatchContract();

            var request = new RestRequest("matches/{matchId}?Authorization={authToken}", Method.GET);

            request.AddParameter("matchId", matchId, ParameterType.UrlSegment);

            return(ExecuteCall <MatchContract>(request));
        }
Ejemplo n.º 3
0
        public static Match MatchContractToMatch(MatchContract m)
        {
            Match match = new Match();

            match.ID           = m.ID;
            match.Jedi1        = JediAdapter.JediContractToJedi(m.Jedi1);
            match.Jedi2        = JediAdapter.JediContractToJedi(m.Jedi2);
            match.Vainqueur    = JediAdapter.JediContractToJedi(m.Vainqueur);
            match.PhaseTournoi = (EPhaseTournoi)m.PhaseTournoi;
            match.Stade        = StadeAdapter.StadeContractToStade(m.Stade);

            return(match);
        }
Ejemplo n.º 4
0
        public ActionResult Create(MatchContract match)
        {
            ServiceClient webService = new ServiceClient();

            try
            {
                webService.AddMatch(match);
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Ejemplo n.º 5
0
        public ActionResult Create(MatchContract match)
        {
            ServiceClient webService = new ServiceClient();

            try
            {
                webService.AddMatch(match);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 6
0
        public ActionResult Delete(int id, MatchContract match)
        {
            ServiceClient webService = new ServiceClient();

            try
            {
                webService.DelMatch(match);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Ejemplo n.º 7
0
        public ActionResult Delete(int id, MatchContract match)
        {
            ServiceClient webService = new ServiceClient();

            try
            {
                webService.DelMatch(match);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Adapte un Match Model en Match Contract.
        /// </summary>
        /// <param name="matchC">Match à adapter.</param>
        /// <returns>Match Model.</returns>
        public static MatchModel fromMatchContract(MatchContract matchC)
        {
            if (matchC == null)
                return null;

            MatchModel m = new MatchModel();
            m.ID = matchC.ID;
            m.IdVainqueur = matchC.IdVainqueur;
            m.Jedi1 = JediAdapter.fromJediContract(matchC.Jedi1);
            m.Jedi2 = JediAdapter.fromJediContract(matchC.Jedi2);
            m.PhaseTournoi = MatchAdapter.fromPhaseTournoiContract(matchC.PhaseTournoi);
            m.Stade = StadeAdapter.fromStadeContract(matchC.Stade);

            return m;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Adapte un Match Model en Match Contract.
        /// </summary>
        /// <param name="match">Match à adapter.</param>
        /// <returns>Match contract.</returns>
        public static MatchContract fromMatchModel(MatchModel match)
        {
            if (match == null)
                return null;

            // Prépare les valeurs
            JediContract jc1 = JediAdapter.fromJediModel(match.Jedi1);
            JediContract jc2 = JediAdapter.fromJediModel(match.Jedi2);
            EPhaseTournoiContract pc = MatchAdapter.fromPhaseTournoiModel(match.PhaseTournoi);
            StadeContract sc = StadeAdapter.fromStadeModel(match.Stade);

            // Crée le MatchContract
            MatchContract mc = new MatchContract();
            mc.ID = match.ID;
            mc.IdVainqueur = match.IdVainqueur;
            mc.Jedi1 = jc1;
            mc.Jedi2 = jc2;
            mc.PhaseTournoi = pc;
            mc.Stade = sc;

            return mc;
        }
Ejemplo n.º 10
0
 public void UpdateMatch(MatchContract match)
 {
     jtm.UpdateMatch(MatchAdapter.MatchContractToMatch(match));
 }
Ejemplo n.º 11
0
 public void DelMatch(MatchContract match)
 {
     jtm.DelMatch(MatchAdapter.MatchContractToMatch(match));
 }
Ejemplo n.º 12
0
        public MatchContract AddMatch(MatchContract match)
        {
            jtm.AddMatch(MatchAdapter.MatchContractToMatch(match));

            return(match);
        }