Example #1
0
 public AchievementsTrigger CreateAchievementTrigger(ActionTriggerViewModel viewModel)
 {
     var achievementTrigger = Mapper.Map<ActionTriggerViewModel, AchievementsTrigger>(viewModel);
     var achievement = this.achievementsRepository.GetById(viewModel.Achievements.Id);
     achievementTrigger.Achievement = achievement;
     return achievementTrigger;
 }
        public void ToAddOrRemoveStatusTriggerTest()
        {
            const string title = "some title";
            var viewModel = new ActionTriggerViewModel();
            viewModel.Title = title;
            viewModel.AchievementAction = AssignUnassign.Assign;
            viewModel.Statuses = new DataSource();
            viewModel.StatusAction = AssignUnassign.Unassign;

            var trigger = Mapper.Map<ActionTriggerViewModel, AchievementsTrigger>(viewModel);

            trigger.Title.Should().Be.EqualTo(title);
            trigger.ActionWithAchievement.Should().Be.EqualTo(AssignUnassign.Assign);
        }
Example #3
0
        public ActionResult Save(int projectId, ActionTriggerViewModel triggerViewModel)
        {
            if (!ModelState.IsValid)
                return View("Add", triggerViewModel);

            if (triggerViewModel.Id == 0)
            {
                ActionTrigger actionTrigger;
                switch (triggerViewModel.TriggersTypes)
                {
                    case TriggersTypes.Achievement:
                        actionTrigger = CreateAchievementTrigger(triggerViewModel);
                        break;
                    case TriggersTypes.ChangePoints:
                        actionTrigger = CreateChangePointsTrigger(triggerViewModel);
                        break;
                    case TriggersTypes.AddOrRemoveStatus:
                        actionTrigger = CreateStatusTrigger(triggerViewModel);
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
                }

                actionTrigger.Project = this.projectsRepository.GetById(projectId);
                this.triggersRepository.AddPhysically(actionTrigger);
            }
            else
            {

            }
            return this.RedirectToAction<ProjectsController>(x => x.Show(projectId));
        }
Example #4
0
 public AddOrRemoveStatusTrigger CreateStatusTrigger(ActionTriggerViewModel viewModel)
 {
     var statusTrigger = Mapper.Map<ActionTriggerViewModel, AddOrRemoveStatusTrigger>(viewModel);
     statusTrigger.Status = this.statusesRepository.GetById(viewModel.Statuses.Id);
     return statusTrigger;
 }
Example #5
0
 public ChangePointsTrigger CreateChangePointsTrigger(ActionTriggerViewModel viewModel)
 {
     var pointsTrigger = Mapper.Map<ActionTriggerViewModel, ChangePointsTrigger>(viewModel);
     return pointsTrigger;
 }