Пример #1
0
        public IActionResult GetById(string serverId)
        {
            DatabaseServer server = DocumentSession
                                    .Include <DatabaseServer>(databaseServer => databaseServer.TenantId)
                                    .Load <DatabaseServer>(serverId);

            if (server == null)
            {
                return(NotFound(new
                {
                    Id = serverId,
                    EntityType = "DatabaseServer",
                    Message = $"No server found with Id {serverId}."
                }));
            }

            Tenant tenant = DocumentSession.Load <Tenant>(server.TenantId);

            if (tenant == null)
            {
                return(NotFound(new
                {
                    Id = server.TenantId,
                    EntityType = "Tenant",
                    Message = $"No tenant found with Id {server.TenantId} (referenced by server {serverId})."
                }));
            }

            return(Json(
                       new DatabaseServerDetail(server, tenant)
                       ));
        }
Пример #2
0
        public AppsList Topic(string topicId)
        {
            var topic = DocumentSession
                        .Include <AppsList>(t => t.Apps)
                        .Load <AppsList>(topicId);

            return(topic);
        }
Пример #3
0
        public override void Execute()
        {
            var post = DocumentSession
                       .Include <Post>(x => x.AuthorId)
                       .Include(x => x.CommentsId)
                       .Load(postId);
            var postAuthor = DocumentSession.Load <User>(post.AuthorId);
            var comments   = DocumentSession.Load <PostComments>(post.CommentsId);

            var comment = new PostComments.Comment
            {
                Id              = comments.GenerateNewCommentId().ToString(),
                Author          = commentInput.Name,
                Body            = commentInput.Body,
                CreatedAt       = DateTimeOffset.Now,
                Email           = commentInput.Email,
                Url             = commentInput.Url,
                Important       = requestValues.IsAuthenticated,                           // TODO: Don't mark as important based on that
                UserAgent       = requestValues.UserAgent,
                UserHostAddress = requestValues.UserHostAddress,
            };

            comment.IsSpam = AkismetService.CheckForSpam(comment);

            var commenter = DocumentSession.GetCommenter(commentInput.CommenterKey) ?? new Commenter {
                Key = commentInput.CommenterKey ?? Guid.Empty
            };

            SetCommenter(commenter, comment);

            if (requestValues.IsAuthenticated == false && comment.IsSpam)
            {
                if (commenter.NumberOfSpamComments > 4)
                {
                    return;
                }

                comments.Spam.Add(comment);
            }
            else
            {
                post.CommentsCount++;
                comments.Comments.Add(comment);
            }

            SendNewCommentEmail(post, comment, postAuthor);
        }
Пример #4
0
        public IActionResult GetById(string databaseId)
        {
            DatabaseInstance database = DocumentSession
                                        .Include <DatabaseInstance>(db => db.TenantId)
                                        .Include <DatabaseInstance>(db => db.ServerId)
                                        .Load <DatabaseInstance>(databaseId);

            if (database == null)
            {
                return(NotFound(new
                {
                    Id = databaseId,
                    EntityType = "Database",
                    Message = $"Database not found with Id '{databaseId}'."
                }));
            }

            Tenant tenant = DocumentSession.Load <Tenant>(database.TenantId);

            if (tenant == null)
            {
                return(NotFound(new
                {
                    Id = database.ServerId,
                    EntityType = "Tenant",
                    Message = $"Database {databaseId}'s tenant not found with Id '{database.TenantId}'."
                }));
            }

            DatabaseServer server = DocumentSession.Load <DatabaseServer>(database.ServerId);

            if (server == null)
            {
                return(NotFound(new
                {
                    Id = database.ServerId,
                    EntityType = "DatabaseServer",
                    Message = $"Database {databaseId}'s server not found with Id '{database.ServerId}'."
                }));
            }

            return(Json(
                       new DatabaseInstanceDetail(database, server, tenant)
                       ));
        }
Пример #5
0
        public ActionResult Topic(string topicId)
        {
            var topic = DocumentSession
                        .Include <AppsList>(t => t.Apps)
                        .Load <AppsList>(topicId);

            if (topic == null)
            {
                Response.StatusCode        = 404;
                Response.StatusDescription = "The requested topic was not found";
                return(View("Topic", null));
            }

            var apps = DocumentSession.Load <App>(topic.Apps);

            return(View("Topic", new TopicViewModel
            {
                Topic = topic,
                Apps = apps.Where(a => a != null)
            }));
        }
Пример #6
0
        public ActionResult EditPlayers(string rosterId)
        {
            Roster roster = DocumentSession
                            .Include <Roster>(r => r.Players)
                            .Load <Roster>(rosterId);

            if (roster == null)
            {
                throw new HttpException(404, "Roster not found");
            }

            var availablePlayers = DocumentSession.Query <Player, PlayerSearch>()
                                   .OrderBy(x => x.Name)
                                   .Where(p => p.PlayerStatus == Player.Status.Active)
                                   .ToList();

            var vm = new EditRosterPlayersViewModel
            {
                RosterViewModel  = DocumentSession.LoadRosterViewModel(roster),
                AvailablePlayers = availablePlayers.Select(x => new PlayerViewModel(x, WebsiteRoles.UserGroup().ToDict())).ToArray()
            };

            return(View(vm));
        }