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); } }
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); }
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); }
public List <DTO_OpenDraw> StartDraw(DTO_OpenDraw draw) { List <DTO_OpenDraw> list = new List <DTO_OpenDraw>(); using (DB_122744_doodleEntities db = new DB_122744_doodleEntities()) { int?temp = 2; db.draws.Where(c => c.DrawID == draw.DrawID).FirstOrDefault().DrawStatusID = temp; db.SaveChanges(); } list.Add(draw); return(list); }
public async Task WS_GatherOpenDraws() { DTO_OpenDraw draw = new DTO_OpenDraw(); List <DTO_OpenDraw> drawList; try { HttpResponseMessage response = await client.PostAsJsonAsync(string.Format(@"{0}{1}", URL, "GetOpenDraws"), draw); response.EnsureSuccessStatusCode(); var json = await response.Content.ReadAsStringAsync(); var des = (Wrapper <DTO_OpenDraw>)Newtonsoft.Json.JsonConvert.DeserializeObject(json, typeof(Wrapper <DTO_OpenDraw>)); drawList = des.Data.ToList(); S_DrawList.Instance.drawList = drawList; } catch (HttpRequestException hre) { Debug.WriteLine(hre.Message); } }
public List <DTO_OpenDraw> GetOpenDraws(List <DTO_OpenDraw> list) { using (DB_122744_doodleEntities db = new DB_122744_doodleEntities()) { int temp = 2; var sqllist = db.draws.Where(c => c.DrawStatusID.Value == temp).ToList(); foreach (var s in sqllist) { DTO_OpenDraw o = new DTO_OpenDraw(); o.Doodler = "Test Doodler"; o.DrawCategoryName = "Test DrawCategoryName"; o.DrawID = s.DrawID; if (s.StartTime.HasValue) { o.StartTime = s.StartTime; } o.DrawStatusDesc = "Test DrawStatusDesc"; list.Add(o); } return(list); } }