Exemple #1
0
        private async void BTN_DLobbySubmit_Click(object sender, RoutedEventArgs e)
        {
            DTO_NewDraw draw = new DTO_NewDraw();

            draw.DoodlerID      = S_User.Instance.userID;
            draw.Answer         = TBox_GGameAnswer.Text;
            draw.StartTime      = null;
            draw.DrawCategoryID = CBox_GGameCategory.SelectedIndex + 1;

            DTO_OpenDraw newdraw = await WS_CreateDraw(draw);

            S_Draw.Instance.drawCategoryName = newdraw.DrawCategoryName;
            S_Draw.Instance.drawID           = newdraw.DrawID;
            S_Draw.Instance.doodleUserID     = S_User.Instance.userID;
            S_Draw.Instance.drawStatusDesc   = newdraw.DrawStatusDesc;
            S_Draw.Instance.drawStatusID     = 1;
            S_Draw.Instance.categoryID       = draw.DrawCategoryID.Value;
            S_Draw.Instance.startTime        = newdraw.StartTime;
            //S_Draw.Instance.drawStatusID =

            /*
             * while(GV_Draw.StartTime > System.DateTime.Now)
             * {
             *  TBlock_GGameStartTimer.Text = (GV_Draw.StartTime - System.DateTime.Now).ToString();
             * }
             */
            DrawPage_DGame();
            await WS_StartDraw(newdraw);
        }
Exemple #2
0
        public List <DTO_OpenDraw> CreateDraw(DTO_NewDraw draw)
        {
            using (DB_122744_doodleEntities db = new DB_122744_doodleEntities())
            {
                List <DTO_OpenDraw> openDrawList = new List <DTO_OpenDraw>();
                DTO_OpenDraw        openDraw     = new DTO_OpenDraw();

                int?  temp   = 1;
                draws sqlobj = new draws();
                sqlobj.CategoryID    = draw.DrawCategoryID;
                sqlobj.DoodlerUserID = draw.DoodlerID;
                sqlobj.Answer        = draw.Answer;
                sqlobj.DrawStatusID  = temp;
                sqlobj.StartTime     = draw.StartTime;
                sqlobj.EndTime       = System.DateTime.Now;
                db.draws.Add(sqlobj);
                db.SaveChanges();

                int temp2 = 1;
                openDraw.DrawID = sqlobj.DrawID;
                //openDraw.Doodler = db.users.Where(c => c.UserID.Equals(draw.DoodlerID)).FirstOrDefault().DisplayName;
                //openDraw.DrawStatusDesc = db.drawStatus.Where(c => c.DrawStatusID.Equals(temp2)).FirstOrDefault().DrawStatusDesc;
                //openDraw.DrawCategoryName = db.drawCategories.Where(c => c.DrawCategoryID.Equals(draw.DrawCategoryID)).FirstOrDefault().DrawCategoryName;
                openDraw.Doodler          = "Test Doodler";
                openDraw.DrawStatusDesc   = "Test DrawStatusDesc";
                openDraw.DrawCategoryName = "Test DrawCategoryName";
                openDraw.StartTime        = System.DateTime.Now;
                openDrawList.Add(openDraw);

                return(openDrawList);
            }
        }
Exemple #3
0
        public async Task <DTO_OpenDraw> WS_CreateDraw(DTO_NewDraw draw)
        {
            DTO_OpenDraw openDraw = new DTO_OpenDraw();

            try
            {
                HttpResponseMessage response = await client.PostAsJsonAsync(string.Format(@"{0}{1}", URL, "CreateDraw"), draw);

                response.EnsureSuccessStatusCode();
                var json = await response.Content.ReadAsStringAsync();

                var des      = (Wrapper <DTO_OpenDraw>)Newtonsoft.Json.JsonConvert.DeserializeObject(json, typeof(Wrapper <DTO_OpenDraw>));
                var drawList = des.Data.ToList();

                if (drawList.Count == 1)
                {
                    openDraw = drawList.FirstOrDefault();
                }
                else
                {
                    openDraw = null;
                }
            }
            catch (Newtonsoft.Json.JsonSerializationException hre)
            {
                Debug.WriteLine(hre.Message);
            }
            return(openDraw);
        }