Exemplo n.º 1
0
        public ActionResult Save(int projectId, string achievementTitle, FileViewModel achievementImage)
        {
            if (achievementImage == null)
            {
                ModelState.AddGeneralError("Achievement file required");
                return this.RedirectToAction<ProjectsController>(x => x.Index());
            }

            if (achievementTitle.IsNullOrBlank())
            {
                ModelState.AddGeneralError("Achievement title required");
                return this.RedirectToAction<ProjectsController>(x => x.Index());
            }

            var achievement = new Achievement();
            var project = this.projectsRepository.GetById(projectId);
            achievement.Project = project;
            achievement.Name = achievementTitle;
            achievementsRepository.AddPhysically(achievement);

            achievement.ImageName = storage.SaveAchievementImage(achievementImage.InputStream, achievementImage.Name);
            this.achievementsRepository.SaveChanges();

            return this.RedirectToAction<ProjectsController>(x => x.Show(projectId));
        }
Exemplo n.º 2
0
        public void GetAchievementTriggerFromDb_ShouldAlwaysIncludeAchievement()
        {
            var repository = this.Container.Resolve<IRepository<AchievementsTrigger>>();
            var achievementRepository = this.Container.Resolve<IRepository<Achievement>>();
            var achievement = new Achievement { Name = "achievement" };
            achievementRepository.AddPhysically(achievement);
            var achievementTrigger = new AchievementsTrigger();
            achievementTrigger.Achievement = achievement;
            repository.AddPhysically(achievementTrigger);
            repository.ClearContext();
            var container = IntegrationTestsComponentRegistration.CreateTestsWindsorContainer();
            var newRepo = container.Resolve<IRepository<AchievementsTrigger>>();

            var triggerFromDb = newRepo.GetById(achievementTrigger.Id);

            triggerFromDb.Achievement.Should().Not.Be.Null();
            triggerFromDb.Achievement.Name.Should().Be.EqualTo("achievement");
        }
Exemplo n.º 3
0
 public string FullAchievementPath(Achievement achievement)
 {
     return this.urlHelper.Content(achievementVirualPath + achievement.ImageName);
 }
Exemplo n.º 4
0
 public static string Path(this UrlHelper urlHelper, Achievement achievement)
 {
     return new Storage(urlHelper).FullAchievementPath(achievement);
 }