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; } }
public bool InsertGoalRules(GoalRule gr) { GoalRule goalrule = new GoalRule(); goalrule.Performance_RangeFrom = gr.Performance_RangeFrom; goalrule.Performance_RangeTo = gr.Performance_RangeTo; goalrule.Rating = gr.Rating; goalrule.GoalId = gr.GoalId; return this._goalruleRepository.InsertGoalRuleDB(goalrule); }
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); }
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); }
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; } }