예제 #1
0
        private void LoadGoals()
        {
            var list = new GoalServices().GetByReviewID(Convert.ToInt32(HttpContext.Current.Request.Url.Segments[HttpContext.Current.Request.Url.Segments.Count() - 1]));

            dlComments.DataSource = list;
            dlComments.DataBind();
        }
예제 #2
0
        public void Test_UpsertGoalsService_Exception()
        {
            var goalsService = new GoalServices(_goalsRepository.Object);

            Assert.ThrowsAsync <Exception>(() => goalsService.UpsertGoalsService(new List <GoalModel>()
            {
                new GoalModel()
                {
                    Id           = 1,
                    Amount       = 5,
                    TargetAmount = 50,
                    GoalName     = "Name",
                    GoalSummary  = "Summary",
                    StartDate    = DateTime.Now,
                    EndDate      = DateTime.Now
                },
                new GoalModel()
                {
                    Id           = 1,
                    UserId       = 5,
                    Amount       = 5,
                    TargetAmount = 50,
                    GoalName     = "Name",
                    GoalSummary  = "Summary",
                    StartDate    = DateTime.Now,
                    EndDate      = DateTime.Now
                }
            }
                                                                                 ));

            _goalsRepository.Verify(g => g.UpsertGoals(It.IsAny <List <Goal> >()), Times.Never);
        }
예제 #3
0
        public async Task Test_UpsertGoalsService_Success()
        {
            _goalsRepository.Setup(g => g.UpsertGoals(It.IsAny <List <Goal> >()))
            .Returns(Task.CompletedTask);

            var goalsService = new GoalServices(_goalsRepository.Object);
            await goalsService.UpsertGoalsService(new List <GoalModel>() {
                new GoalModel()
                {
                    Id           = 1,
                    UserId       = 5,
                    Amount       = 5,
                    TargetAmount = 50,
                    GoalName     = "Name",
                    GoalSummary  = "Summary",
                    StartDate    = DateTime.Now,
                    EndDate      = DateTime.Now
                },
                new GoalModel()
                {
                    Id           = 1,
                    UserId       = 5,
                    Amount       = 5,
                    TargetAmount = 50,
                    GoalName     = "Name",
                    GoalSummary  = "Summary",
                    StartDate    = DateTime.Now,
                    EndDate      = DateTime.Now
                }
            }
                                                  );

            _goalsRepository.Verify(g => g.UpsertGoals(It.IsAny <List <Goal> >()), Times.Once);
        }
예제 #4
0
        protected async Task DeleteGoal(GoalViewModel goal)
        {
            System.Console.WriteLine($"Deleting goal {goal.Id}");
            await GoalServices.DeleteAsync(goal);

            await OnInitializedAsync();
        }
예제 #5
0
        private GoalServices CreateGoalServices()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new GoalServices(userId);

            return(service);
        }
예제 #6
0
        // GET: Goal
        public ActionResult Index()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new GoalServices(userId);
            var model   = service.GetGoals();

            return(View(model));
        }
예제 #7
0
 // GET: AddItem
 public AddItemController()
 {
     _teamServices        = new TeamServices();
     _workstreamServices  = new WorkstreamServices();
     _categoryServices    = new CategoryServices();
     _subCategoryServices = new SubcategoryServices();
     _goalServices        = new GoalServices();
 }
예제 #8
0
        public void Test_UpsertGoalsService_BadArgument()
        {
            var goalsService = new GoalServices(_goalsRepository.Object);

            Assert.ThrowsAsync <ArgumentException>(() => goalsService.UpsertGoalsService(null));

            _goalsRepository.Verify(g => g.UpsertGoals(It.IsAny <List <Goal> >()), Times.Never);
        }
예제 #9
0
 public void UpdateGoalWeight(IList <GoalWeight> weights)
 {
     foreach (var w in weights)
     {
         var goal = new GoalServices().GetByID(w.ID);
         goal.Weight = w.Weight;
         new GoalServices().Save(goal);
     }
 }
예제 #10
0
        public async Task Test_GetGoalsService_Success()
        {
            _goalsRepository.Setup(g => g.GetGoals(It.IsAny <long>()))
            .ReturnsAsync(new List <Goal>());

            var goalsService = new GoalServices(_goalsRepository.Object);
            await goalsService.GetGoalsService(1);

            _goalsRepository.Verify(g => g.GetGoals(It.IsAny <long>()), Times.Once);
        }
예제 #11
0
        public void Test_GetGoalsService_Exception()
        {
            _goalsRepository.Setup(g => g.GetGoals(It.IsAny <long>()));

            var goalsService = new GoalServices(_goalsRepository.Object);

            Assert.ThrowsAsync <Exception>(() => goalsService.GetGoalsService(1));

            _goalsRepository.Verify(g => g.GetGoals(It.IsAny <long>()), Times.Once);
        }
예제 #12
0
        protected async Task SaveGoal()
        {
            System.Console.WriteLine($"Saving goal {CurrentGoal.Id.ToString()}");

            await GoalServices.SaveAsync(CurrentGoal, Updating);

            // Refresh list and reset the form
            Updating    = false;
            CurrentGoal = new GoalViewModel();
            await OnInitializedAsync();
        }
예제 #13
0
        public void Test_GetGoalsService_ArgumentException()
        {
            _goalsRepository.Setup(g => g.GetGoals(It.IsAny <long>()))
            .ReturnsAsync(new List <Goal>());

            var goalsService = new GoalServices(_goalsRepository.Object);

            Assert.ThrowsAsync <ArgumentException>(() => goalsService.GetGoalsService(0));

            _goalsRepository.Verify(g => g.GetGoals(It.IsAny <long>()), Times.Never);
        }
예제 #14
0
        private void LoadTemplates()
        {
            PagedDataSource pd = new PagedDataSource();

            var list = new GoalServices().GetTemplates().OrderBy(o => o.DateCreated).ToList <Goal>();

            pd.DataSource       = list;
            pd.AllowPaging      = true;
            pd.PageSize         = 50;
            pd.CurrentPageIndex = CurrentPage;
            lblCurrentPage.Text = "Page: "
                                  + (CurrentPage + 1).ToString()
                                  + " of "
                                  + pd.PageCount.ToString();
            cmdPrev.Enabled = !pd.IsFirstPage;
            cmdNext.Enabled = !pd.IsLastPage;

            dlPeople.DataSource = pd;
            dlPeople.DataBind();
        }
예제 #15
0
        protected void DeleteGoalClicked(object o, EventArgs e)
        {
            var goal = new GoalServices().GetByID(Convert.ToInt32(((LinkButton)o).Attributes["itemid"]));

            foreach (var milestone in goal.Milestones)
            {
                new GoalMilestoneServices().Delete(milestone);
            }

            foreach (var subscriber in goal.Managers)
            {
                new GoalManagerServices().Delete(subscriber);
            }

            foreach (var note in goal.Communication)
            {
                new GoalCommunicationServices().Delete(note);
            }
            new GoalServices().Delete(goal);
            Response.Redirect(SecurityContextManager.Current.CurrentURL);
        }
예제 #16
0
        protected void DeleteGoalClicked(object o, EventArgs e)
        {
            var item = (IdeaSeed.Web.UI.LinkButton)o;
            var goal = new GoalServices().GetByID(Convert.ToInt32(item.Attributes["itemid"]));

            foreach (var ms in new GoalMilestoneServices().GetByGoalID(goal.ID))
            {
                new GoalMilestoneServices().Delete(ms);
            }

            foreach (var communication in new GoalCommunicationServices().GetByGoalID(goal.ID))
            {
                new GoalCommunicationServices().Delete(communication);
            }

            foreach (var manager in new GoalManagerServices().GetByGoalID(goal.ID))
            {
                new GoalManagerServices().Delete(manager);
            }
            new GoalServices().Delete(goal);
            LoadGoals();
        }
예제 #17
0
 public GoalsBase(GoalServices goalServices)
 {
     GoalServices = goalServices;
 }
예제 #18
0
 protected override async Task OnInitializedAsync()
 {
     Goals = (await GoalServices.GetAllAsync()).ToList();
 }