Пример #1
0
        public async Task <ActionResult> DoMessage()
        {
            var owner = c.Users.Include("Clients").First(u => u.UserName == User.Identity.Name);

            LogMessageSyndication.ReportMessage(new Models.LogMessage()
            {
                Title    = "A new Title " + DateTimeOffset.Now.ToString(),
                Body     = "Body " + DateTimeOffset.Now.ToString(),
                Category = "ERROR",
                Message  = "Here is a message",
                Client   = owner.Clients.First()
            });
            return(Content("Created"));
        }
Пример #2
0
        public async Task <IHttpActionResult> PostLogMessage(LogMessage logmessage)
        {
            var client = GetClientFromHeaders();

            client.LogMessages.Add(logmessage);
            if (null == logmessage)
            {
                return(BadRequest("No log message was present"));
            }
            logmessage.Client = client;
            ModelState.Remove("logmessage.Client");
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await data.SaveChangesAsync();

            LogMessageSyndication.ReportMessage(logmessage);
            return(CreatedAtRoute("DefaultApi", new { id = logmessage.LogMessageId }, logmessage));
        }