Пример #1
0
        public IHttpActionResult Put(Guid Id, [FromBody] MessageModel m)
        {
            if (m != null)
            {
                try
                {
                    MessageModel original = MessageSqlDbAccess.GetById(Id);

                    if (m.WasRead != null)
                    {
                        original.WasRead = m.WasRead;
                    }
                    if (m.FullName != null)
                    {
                        original.FullName = m.FullName;
                    }
                    if (m.Email != null)
                    {
                        original.Email = m.Email;
                    }
                    if (m.Message != null)
                    {
                        original.Message = m.Message;
                    }

                    MessageSqlDbAccess.Update(original);
                    logger.Info($"MessageController.Put successfully edited {m.Print()}");
                    return(Ok());
                }
                catch (Exception ex)
                {
                    logger.Info($"MessageController.Put threw error {ex.Message} trying to edit {m.Print()}");
                    return(BadRequest());
                }
            }
            else
            {
                logger.Info($"MessageController.Put failed to edit {m.Print()}");
                return(BadRequest());
            }
        }
Пример #2
0
 public JsonResult <MessageModel> Get(Guid Id)
 {
     return(Json <MessageModel>(MessageSqlDbAccess.GetById(Id)));
 }