public IActionResult addMessage(MessageViewModel model) { Response oReply = new Response(); oReply.Result = 0; string token = Request.Headers["X-Signature"]; if (verifyXSignature(token)) { try { using (masterDevContext db = new masterDevContext()) { Message oMessage = new Message(); oMessage.Message1 = model.Message1; oMessage.Tag = model.Tag; db.Message.Add(oMessage); db.SaveChanges(); oReply.Result = 200; } } catch (Exception ex) { Console.WriteLine(ex.Message); } } else { oReply.Message = "Please authenticate before realize the query"; } return(Ok(oReply)); }
public IActionResult add(CredentialViewModel model) { Response oReply = new Response(); oReply.Result = 0; string convertString = this.HMACSHA256(model.UserKey); try { if (!verificarToken(model.UserKey)) { using (masterDevContext db = new masterDevContext()) { Credential oModel = new Credential(); oModel.Userkey = model.UserKey; oModel.Sharedsecret = convertString; db.Credential.Add(oModel); db.SaveChanges(); oReply.Result = 204; oReply.Data = convertString; } } else { oReply.Result = 403; oReply.Data = convertString; } }catch (Exception s) { Console.WriteLine(s.Message); } return(Ok(oReply)); }
public IActionResult searchTag([FromQuery] string Tag) { Response oReply = new Response(); oReply.Result = 0; string token = Request.Headers["X-Signature"]; if (verifyXSignature(token)) { try { using (masterDevContext db = new masterDevContext()) { var query = (from d in db.Message where d.Tag.Contains(Tag) select d).ToList(); oReply.Data = query; oReply.Result = 200; } } catch (Exception ex) { Console.WriteLine(ex.Message); } } else { oReply.Message = "Please authenticate before realize the query"; } return(Ok(oReply)); }
public IActionResult searchId(int Id) { Response oReply = new Response(); oReply.Result = 0; string token = Request.Headers["X-Signature"]; if (verifyXSignature(token)) { try { using (masterDevContext db = new masterDevContext()) { var query = db.Message.Find(Id); oReply.Data = query; oReply.Result = 200; } } catch (Exception ex) { Console.WriteLine(ex.Message); } } else { oReply.Message = "Please authenticate before realize the query"; } return(Ok(oReply)); }
public IActionResult getCredential() { Response oReply = new Response(); oReply.Result = 0; using (masterDevContext db = new masterDevContext()) { var query = db.Credential.ToList(); oReply.Data = query; } return(Ok(oReply)); }
public bool verifyCodeXSignature(string convertString) { using (var db = new masterDevContext()) { var existUser = from d in db.Credential where d.Sharedsecret == convertString select d; if (existUser.FirstOrDefault() != null) { return(true); } else { return(false); } } }
public bool verificarToken(string userKey) { String convertString = this.HMACSHA256(userKey); using (var db = new masterDevContext()) { var existUser = from d in db.Credential where d.Sharedsecret == convertString select d; if (existUser.FirstOrDefault() != null) { return(true); } else { return(false); } } }