예제 #1
0
 public bool CreateGoal(GoalMaster goal)
 {
     try
     {
         var CheckQuarter = _quarterServices.CheckQuarter(goal.GoalQuarter, goal.QuarterYear);
         if (CheckQuarter != null)
         {
             goal.QuarterID = CheckQuarter.QuarterID;
             int goalId = _goalRepository.InsertGoalMasterDB(goal);
             if (goalId != -1)
             {
                 foreach (GoalRule rule in goal.GoalRules)
                 {
                     GoalRule gr = new GoalRule();
                     gr.Performance_RangeFrom = rule.Performance_RangeFrom;
                     gr.Performance_RangeTo = rule.Performance_RangeTo;
                     gr.Rating = rule.Rating;
                     gr.GoalId = goalId;
                     _ruleServices.InsertGoalRules(gr);
                 }
                 return true;
             }
             else
             {
                 this.ValidationErrors.Add("ERR_GOAL_ID", "Inserted goal id not found!");
             }
         }
         return false;
     }
     catch
     {
         this.ValidationErrors.Add("ERR_ADD_GOAL", "Error ocurred while Creating Goal!");
         return false;
     }
 }
예제 #2
0
 public void CreateGoalTest()
 {
     GoalMaster goal = new GoalMaster();
     goal.GoalTitle = "Testing goal";
     goal.GoalDescription = "goal testing description";
     goal.UnitOfMeasurement = "Days";
     goal.MeasurementValue = 12;
     goal.GoalQuarter = 4;
     goal.QuarterYear = 2015;
     GoalRule rule = new GoalRule();
     rule.Performance_RangeFrom = 10;
     rule.Performance_RangeTo = 50;
     rule.Rating = 60;
     goal.GoalRules = new List<GoalRule>();
     goal.GoalRules.Add(rule);
     bool isSuccess = _goalServices.CreateGoal(goal);
     Assert.AreEqual(true, isSuccess);
 }
예제 #3
0
 public void UpdateGoalTest()
 {
     GoalMaster goal = new GoalMaster();
     goal.Goal_MasterID = 12;
     goal.GoalTitle = "Testing Update goal";
     goal.GoalDescription = "Add goal description here";
     goal.UnitOfMeasurement = "hours";
     goal.MeasurementValue = 40;
     goal.GoalQuarter = 4;
     goal.QuarterYear = 2015;
     GoalRule rule = new GoalRule();
     rule.Performance_RangeFrom = 70;
     rule.Performance_RangeTo = 90;
     rule.Rating = 80;
     goal.GoalRules = new List<GoalRule>();
     goal.GoalRules.Add(rule);
     bool isSuccess = _goalServices.UpdateGoal(goal);
     Assert.AreEqual(true, isSuccess);
 }
예제 #4
0
 public bool UpdateGoal(GoalMaster goal)
 {
     try
     {
         var quarter = _quarterServices.CheckQuarter(goal.GoalQuarter, goal.QuarterYear);
         goal.QuarterID = quarter.QuarterID;
         _goalRepository.UpdateGoalMasterDB(goal);
         _ruleServices.DeleteAllGoalRule(goal.Goal_MasterID);
         foreach (GoalRule rule in goal.GoalRules)
         {
             GoalRule gr = new GoalRule();
             gr.Performance_RangeFrom = rule.Performance_RangeFrom;
             gr.Performance_RangeTo = rule.Performance_RangeTo;
             gr.Rating = rule.Rating;
             gr.GoalId = goal.Goal_MasterID;
             _ruleServices.InsertGoalRules(gr);
         }
         return true;
     }
     catch
     {
         this.ValidationErrors.Add("ERR_EDIT_GOAL", "Error Ocurred while Updating Goal!");
         return false;
     }
 }
        public JsonResult CreateGoal(GoalMaster GoalData)
        {
            try
            {
                var IsCreate = _goalServices.CreateGoal(GoalData);
                if (IsCreate)
                {
                    return Json(new JsonResponse { message = "Goal created successfully!", success = true });
                }
                else
                {
                    return Json(new JsonResponse { message = "Error occured while creating goal!", success = false });

                }
            }
            catch
            {
                return Json(new JsonResponse { message = "Error occured while creating goal!", success = false });
            }
        }