public HttpResponseMessage GetDetailById(int id, string password) { using (XMas_DatabaseEntities entities = new XMas_DatabaseEntities()) { var L2Enty = entities.Info.Find(id); if (!L2Enty.RandomCode.Contains(password)) { var msg = Request.CreateResponse(); msg.StatusCode = HttpStatusCode.BadRequest; msg.Content = new StringContent("Wrong Password!!"); return(msg); } else { InfoModel.ById_Detail data = new InfoModel.ById_Detail() { Id = L2Enty.Id, PlayerName = L2Enty.PlayerName, Desire = L2Enty.Desire, Tip1 = L2Enty.Tip1, Tip2 = L2Enty.Tip2, Tip3 = L2Enty.Tip3 }; return(Request.CreateResponse(HttpStatusCode.OK, data)); } } }
public HttpResponseMessage GetTips(int id, string password) { using (XMas_DatabaseEntities entities = new XMas_DatabaseEntities()) { var L2Enty = entities.Info.Find(id); if (!L2Enty.RandomCode.Contains(password)) { var msg = Request.CreateResponse(); msg.StatusCode = HttpStatusCode.BadRequest; msg.Content = new StringContent("Wrong Password!!"); return(msg); } else { var Receiver = entities.Info.Find(L2Enty.Receiver); InfoModel.Tips_Detail data = new InfoModel.Tips_Detail() { Tip1 = Receiver.Tip1, Tip2 = Receiver.Tip2, Tip3 = Receiver.Tip3 }; L2Enty.Draw = true; entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, data)); } } }
public HttpResponseMessage PutPassword(int id, [FromBody] InfoModel.Password_Detail password) { try { using (XMas_DatabaseEntities entities = new XMas_DatabaseEntities()) { var L2Enty = entities.Info.Find(id); if (L2Enty == null) { var msg = Request.CreateResponse(); msg.StatusCode = HttpStatusCode.BadRequest; msg.Content = new StringContent("Id not Found"); return(msg); } else if (!L2Enty.RandomCode.Contains(password.oldPassword)) { var msg = Request.CreateResponse(); msg.StatusCode = HttpStatusCode.BadRequest; msg.Content = new StringContent("Wrong Password!!"); return(msg); } else { L2Enty.RandomCode = password.newPassword; entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.BadRequest, L2Enty.RandomCode)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public bool RandomDraw() { List <int> IdList = new List <int>(); using (XMas_DatabaseEntities entities = new XMas_DatabaseEntities()) { var L2Enty = from c in entities.Info.AsNoTracking() orderby c.Id select c; var dataList = L2Enty.Select(s => new Format_Detail() { Id = s.Id, }).ToList <Format_Detail>(); foreach (var data in dataList) { IdList.Add(data.Id); } } bool IsRandom = false; List <int> randomList = new List <int>(); while (!IsRandom) { randomList = ShuffleList(IdList); for (int i = 0; i < IdList.Count; i++) { if (IdList[i] == randomList[i]) { IsRandom = false; break; } if (i == IdList.Count - 1 && IdList[i] != randomList[i]) { IsRandom = true; } } } for (int i = 0; i < IdList.Count; i++) { int id = IdList[i]; using (XMas_DatabaseEntities entities_new = new XMas_DatabaseEntities()) { var exist = entities_new.Info.Find(id); exist.Receiver = randomList[i]; entities_new.SaveChanges(); } } return(true); }
public List <Privacy_Detail> GetAllPrivacy() { using (XMas_DatabaseEntities entities = new XMas_DatabaseEntities()) { var L2Enty = from c in entities.Info.AsNoTracking() orderby c.Id select c; return(L2Enty.Select(s => new Privacy_Detail() { Id = s.Id, PlayerName = s.PlayerName, Apply = s.Apply, Draw = s.Draw }).ToList <Privacy_Detail>()); } }
public HttpResponseMessage PutTips(int id, string password, [FromBody] InfoModel.Apply_Detail apply) { try { using (XMas_DatabaseEntities entities = new XMas_DatabaseEntities()) { var L2Enty = entities.Info.Find(id); if (L2Enty == null) { var msg = Request.CreateResponse(); msg.StatusCode = HttpStatusCode.BadRequest; msg.Content = new StringContent("Id not Found"); return(msg); } else if (!L2Enty.RandomCode.Contains(password)) { var msg = Request.CreateResponse(); msg.StatusCode = HttpStatusCode.BadRequest; msg.Content = new StringContent("Wrong Password!!"); return(msg); } else if (L2Enty.Apply) { var msg = Request.CreateResponse(); msg.StatusCode = HttpStatusCode.BadRequest; msg.Content = new StringContent("Already Apply"); return(msg); } else { L2Enty.Desire = apply.Desire; L2Enty.Tip1 = apply.Tip1; L2Enty.Tip2 = apply.Tip2; L2Enty.Tip3 = apply.Tip3; L2Enty.Apply = true; entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.BadRequest, apply)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public HttpResponseMessage PutStatus(int id, [FromBody] InfoModel.Status_Detail apply) { try { using (XMas_DatabaseEntities entities = new XMas_DatabaseEntities()) { var L2Enty = entities.Info.Find(id); if (L2Enty == null) { var msg = Request.CreateResponse(); msg.StatusCode = HttpStatusCode.BadRequest; msg.Content = new StringContent("Id not Found"); return(msg); } else if (!apply.Auth.Contains("821101")) { var msg = Request.CreateResponse(); msg.StatusCode = HttpStatusCode.BadRequest; msg.Content = new StringContent("Wrong Password!!"); return(msg); } else if (L2Enty.Apply) { var msg = Request.CreateResponse(); msg.StatusCode = HttpStatusCode.BadRequest; msg.Content = new StringContent("Already Apply"); return(msg); } else { L2Enty.Apply = apply.Apply; L2Enty.Draw = apply.Draw; entities.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.BadRequest, apply)); } } } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public List <Format_Detail> GetDetailById(int id, string randomCode) { using (XMas_DatabaseEntities entities = new XMas_DatabaseEntities()) { var L2Enty = from c in entities.Info.AsNoTracking() where c.Id == id && c.RandomCode.Contains(randomCode) select c; return(L2Enty.Select(s => new Format_Detail() { Id = s.Id, RandomCode = s.RandomCode, PlayerName = s.PlayerName, Desire = s.Desire, Tip1 = s.Tip1, Tip2 = s.Tip2, Tip3 = s.Tip3 }).ToList <Format_Detail>()); } }
public List <Format_Detail> GetAll() { using (XMas_DatabaseEntities entities = new XMas_DatabaseEntities()) { var L2Enty = from c in entities.Info.AsNoTracking() orderby c.Id select c; return(L2Enty.Select(s => new Format_Detail() { Id = s.Id, RandomCode = s.RandomCode, PlayerName = s.PlayerName, Tip1 = s.Tip1, Tip2 = s.Tip2, Tip3 = s.Tip3, Apply = s.Apply, Draw = s.Draw, Receiver = s.Receiver, Desire = s.Desire }).ToList <Format_Detail>()); } }