Beispiel #1
0
        public void RuleAvailableInRepository()
        {
            var repository = new RulesRepository();

            Rules.AddTo(repository);
            Assert.That(repository.Get(RuleName), Is.Not.Null);
            Assert.That(repository.GetAll(), Has.One.Matches(Has.Property("Name").EqualTo(RuleName)));
        }
Beispiel #2
0
        public override ActionResult Edit(EditVM model)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("~/Views/Partials/Edits/_EditSubreddit.cshtml", model));
            }
            RulesRepository      ruleRepo = new RulesRepository();
            SubRedditsRepository repo     = new SubRedditsRepository();
            SubReddit            item     = new SubReddit();

            model.PopulateEntity(item);
            model.Rules = ruleRepo.GetAll(a => a.SubRedditId == item.Id);
            repo.Save(item);

            model.Id = item.Id;

            // като създадеш събреддит, автоматично ставаш мод и се събскрайбваш за него
            repo.AddAdminToSubReddit(model.Id, model.UserId);
            repo.Subscribe(model.Id, model.UserId);

            return(Content(""));
        }