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 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)); }