67 lines
2.1 KiB
C#
67 lines
2.1 KiB
C#
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<APIStrategicGoalModel> getGoalsForProject(Guid ProjectId)
|
|
{
|
|
|
|
List<APIStrategicGoalModel> results = new List<APIStrategicGoalModel>();
|
|
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<Guid> ValidateGoals(List<APIStrategicGoalModel> goals)
|
|
{
|
|
var logger = LogManager.GetCurrentClassLogger();
|
|
if (goals == null)
|
|
goals = new List<APIStrategicGoalModel>();
|
|
List<Guid> results = new List<Guid>();
|
|
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;
|
|
}
|
|
}
|
|
}
|