using EnVisage; using EnVisage.Code.BLL; using EnVisage.Models; using NLog; using PrevuWebAPI.Models; using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PrevuWebAPI.Code.Managers { public class APIStrategicGoalManager : BaseManager { public APIClientCallBackManager _callBackManager = new APIClientCallBackManager(); private StrategicGoalManager _manager = new StrategicGoalManager(PrevuEFContext.PrevuEntity); public List getGoalsForProject(Guid ProjectId) { List results = new List(); var sgs = _manager.GetStrategicGoalsForProject(ProjectId); foreach(StrategicGoal sg in sgs) { results.Add(GetAPIModel(sg)); } return results; } private APIStrategicGoalModel GetAPIModel(StrategicGoal m) { return new APIStrategicGoalModel() { StrategicGoalName = m.Name }; } public List ValidateGoals(List goals) { var logger = LogManager.GetCurrentClassLogger(); if (goals == null) goals = new List(); List results = new List(); foreach (APIStrategicGoalModel goal in goals) { var g = _manager.GetStrategicGoalByName(goal.StrategicGoalName); if (g == null || g.Id == Guid.Empty) { if (logger != null) logger.Log(LogLevel.Debug, "Goal NOT loaded:" + goal.StrategicGoalName); } else { results.Add(g.Id); if (logger != null) logger.Log(LogLevel.Debug, "Goal loaded:" + g.Name + "/" + g.Id); } } return results; } } }