예제 #1
0
        new public Recurrent Get(long id)
        {
            var entity =
                Connection.Query <Recurrent>(String.Format("SELECT * FROM {0} where Id = @id", EntityTableSchema),
                                             new { id }).SingleOrDefault();

            if (entity == null)
            {
                return(null);
            }

            entity.Goal = _goalRepository.Get(entity.Id, GoalEntityType.Recurrent);
            return(entity);
        }
예제 #2
0
        new public Saving Get(long id)
        {
            var entity =
                Connection.Query <Saving>(String.Format("SELECT * FROM {0} where Id = @id",
                                                        EntityTableSchema), new { id }).SingleOrDefault();

            if (entity == null)
            {
                return(null);
            }

            entity.Goal = _goalRepository.Get(entity.Id, GoalEntityType.Saving);
            //var reason = _catalogRepository.Get(Catalogs.SAVING_TYPE, entity.ReasonTypeId);
            return(entity);
        }
예제 #3
0
        public IEnumerable <ValidationResult> CanAddGoal(Goal newGoal, IUpdateService updateService)
        {
            Goal goal;

            if (newGoal.GoalId == 0)
            {
                goal = _goalRepository.Get(g => g.GoalName == newGoal.GoalName);
            }
            else
            {
                goal = _goalRepository.Get(g => g.GoalName == newGoal.GoalName && g.GoalId != newGoal.GoalId);
            }
            if (goal != null)
            {
                yield return(new ValidationResult("GoalName", Resources.GoalExists));
            }
            if (newGoal.StartDate.Subtract(newGoal.EndDate).TotalSeconds > 0)
            {
                yield return(new ValidationResult("EndDate", Resources.EndDate));
            }

            int flag   = 0;
            int status = 0;

            if (newGoal.GoalId != 0)
            {
                var updates = updateService.GetUpdatesByGoal(newGoal.GoalId).OrderByDescending(g => g.UpdateDate).ToList();
                if (updates.Any())
                {
                    if ((updates[0].UpdateDate.Subtract(newGoal.EndDate).TotalSeconds > 0))
                    {
                        flag = 1;
                    }
                    if ((newGoal.StartDate.Subtract(updates[0].UpdateDate).TotalSeconds > 0))
                    {
                        status = 1;
                    }
                    if (flag == 1)
                    {
                        yield return(new ValidationResult("EndDate", Resources.EndDateNotValid + " " + updates[0].UpdateDate.ToString("dd-MMM-yyyy")));
                    }
                    else if (status == 1)
                    {
                        yield return(new ValidationResult("StartDate", Resources.StartDate + " " + updates[0].UpdateDate.ToString("dd-MMM-yyyy")));
                    }
                }
            }
        }
        public ActionResult Patch(Goal goal)
        {
            if (goal == null)
            {
                return(NotFound());
            }

            if (_goalRepository.Get(goal.Id) == null)
            {
                return(NotFound(goal.Id));
            }

            _goalRepository.Update(goal);

            return(Created("Goals", goal));
        }
예제 #5
0
        private void UpdateGoalStatus(ReportGoalView reportGoal, int companyId)
        {
            var goal = _goalRepository.Get(reportGoal.Id);

            goal.CompanyId = companyId;
            goal.Status    = reportGoal.Status;
            _goalRepository.Update(goal);
        }
예제 #6
0
        public ActionResult Update(int Id)
        {
            var goal = goalRepository.Get(Id);

            ViewBag.ActionName = "Update";
            ViewBag.Title      = "Edit Goal";
            return(View("EditGoal", goal));
        }
예제 #7
0
 public void UpdateGoal(long id, GoalRequest goalRequest)
 {
     try
     {
         var goal        = _goalRepository.Get(id);
         var goalUpdated = new Goal()
         {
             GoalId     = goal.GoalId,
             JobId      = goal.JobId,
             LocationId = goal.LocationId,
             Status     = goalRequest.Status,
         };
         _goalRepository.Update(goal, goalUpdated);
     }
     catch (Exception e)
     {
         throw new Exception(e.ToString());
     }
 }
예제 #8
0
        public Goal Get(int id)
        {
            var goal = _goalRepository.Get(id);

            return(goal);
        }
예제 #9
0
 public Goal Get(Guid id)
 {
     return(_repository.Get(id));
 }
 public Goal Get(long id)
 {
     return(Repo.Get(id));
 }