Example #1
0
        public EmailProcessing(FetchAllUnseenPop3Client client, PlayersRepo playersRepo, AnswersRepo answersRepo,
		                       TagsRepo tagsRepo, Replier replier)
        {
            this.client = client;
            this.playersRepo = playersRepo;
            this.answersRepo = answersRepo;
            this.tagsRepo = tagsRepo;
            this.replier = replier;
        }
Example #2
0
        public PostsResponse Add(Post post)
        {
            var context  = new PersonalBlogEntities();
            var response = new PostsResponse();

            if (string.IsNullOrEmpty(post.PostTitle))
            {
                response.Success = false;
                response.Message = "The post title cannot be left blank.";
            }
            else if (post.CreatedDate < DateTime.Today.AddDays(1))
            {
                response.Success = false;
                response.Message = "The post cannot have a creation date before the current date.";
            }
            //else if (!post.IsApproved)
            //{
            //    response.Success = false;
            //    response.Message = "This post has content that violates our blogging policy.";
            //}
            else if (string.IsNullOrEmpty(post.PostBody))
            {
                response.Success = false;
                response.Message = "The post body cannot be left blank.";
            }
            else if (context.Categories.FirstOrDefault(c => c.CategoryId == post.CategoryId) == null)
            {
                response.Success = false;
                response.Message = "That category is invalid";
            }
            else
            {
                TagsRepo tagsRepo = new TagsRepo();

                List <Tag> allTags   = tagsRepo.GetAll().Tags.ToList();
                List <Tag> tagsToAdd = post.Tags.AsEnumerable().Where(t => post.Tags.Any(postTag => postTag.TagName != t.TagName)).ToList();
                foreach (Tag t in tagsToAdd)
                {
                    tagsRepo.Add(t);
                }
                response         = repo.Add(post);
                response.Message = $"The post \"{post.PostTitle}\" has been added to the database.";
            }

            return(response);
        }
Example #3
0
 public void Test()
 {
     using (var playersRepo = new PlayersRepo("players"))
     using (var answersRepo = new AnswersRepo("answers"))
     using (var tagsRepo = new TagsRepo("tags"))
     {
         File.WriteAllText("index.html",
                           Razor.Parse(File.ReadAllText("index.cshtml"),
                                       new GameLogic().Calculate(playersRepo, answersRepo, tagsRepo)
                           	));
     }
     Process.Start("index.html");
 }
Example #4
0
 public GameResult[] Calculate(PlayersRepo playersRepo, AnswersRepo answersRepo, TagsRepo tagsRepo)
 {
     return
         tagsRepo.Tags.Select(
             tag => GetResults(tag, playersRepo, answersRepo.GetFor(tag.Tag))).OrderByDescending(res => res.Tag.Finish).ToArray();
 }