Example #1
0
        public ActionResult Edit(Milestone model)
        {
            try
            {
                // TODO: Add update logic here
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                var Milestone = _mapper.Map <Milestone>(model);
                var isSuccess = _repo.Update(Milestone);
                if (!isSuccess)
                {
                    ModelState.AddModelError("", "Something Went Wrong!");
                    return(View(model));
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                ModelState.AddModelError("", "Something Went Wrong!");
                return(View(model));
            }
        }
Example #2
0
        /// <summary>
        /// Updates any milestones that we have now surpassed by creating this transaction
        /// with the current amount -- this updates the database
        /// </summary>
        /// <param name="targetGoalId">The target goal Id</param>
        /// <param name="currentGoalAmount">The current amount of the goal (after the created transaction)</param>
        /// <param name="createdTransaction">The transaction that we have created</param>
        private void UpdateAnyNewlySurpassedMilestones(int?targetGoalId, double currentGoalAmount, Transaction createdTransaction)
        {
            IEnumerable <Milestone> newlySurpassedMilestones = GetNewlySurpassedUpdatedMilestones(createdTransaction, targetGoalId, currentGoalAmount);

            if (newlySurpassedMilestones != null && newlySurpassedMilestones.Any())
            {
                foreach (var milestone in newlySurpassedMilestones)
                {
                    milestoneRepository.Update(milestone.Id, milestone);
                }
            }
        }
Example #3
0
 public void Update(Milestone milestone)
 {
     _milestoneRepository.Update(milestone);
 }
Example #4
0
 /// <summary>
 /// Updates the Milestone on the system with the given ID
 /// using the details of the milestone provided
 /// </summary>
 /// <param name="id">The ID of the milestone</param>
 /// <param name="milestone">The milestone containing new information</param>
 /// <returns>The milestone that was saved on the system</returns>
 public Milestone UpdateMilestone(int id, Milestone milestone)
 {
     //Run the appropriate validations
     ValidateMilestoneExistsAndIsNotCompleted(id);
     return(milestoneRepository.Update(id, milestone));
 }