128 lines
5.0 KiB
C#
128 lines
5.0 KiB
C#
using System.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using EnVisage.Code.DAL.Mongo;
|
|
|
|
namespace EnVisage.Models
|
|
{
|
|
public class MixSaveModel : MixModelBase
|
|
{
|
|
public MixCalendarModel Calendar { get; set; }
|
|
public MixFilterModel Filter { get; set; }
|
|
public bool CanRunResourceRace { get; set; }
|
|
public bool CanRunTeamRace { get; set; }
|
|
public bool canDoRace { get; set; }
|
|
public bool TeamLevelRace { get; set; }
|
|
public MixSaveModel()
|
|
: base()
|
|
{
|
|
Calendar = new MixCalendarModel();
|
|
Filter = new MixFilterModel();
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Copies property values from current object of type <see cref="MixSaveModel"/> to <paramref name="obj"/> object of type <see cref="EnVisage.Code.DAL.Mongo.Mix"/> entity.
|
|
/// </summary>
|
|
/// <param name="obj">An object of <see cref="Mix"/> type.</param>
|
|
public void CopyTo(Mix obj)
|
|
{
|
|
if (obj == null)
|
|
throw new ArgumentNullException("obj");
|
|
obj.Name = Name;
|
|
obj.StartDate = StartDate;
|
|
obj.EndDate = EndDate;
|
|
obj.CreatedBy = CreatedBy;
|
|
obj.Teams = Calendar.Teams.Select(t => new MixTeam
|
|
{
|
|
Id = t.Id,
|
|
Name = t.Name,
|
|
CompanyId = t.CompanyId,
|
|
CostCenterId = t.CostCenterId,
|
|
UserId = t.UserId,
|
|
IsNew = t.IsNew,
|
|
PlannedCapacity = (t.PlannedCapacity != null) ? t.PlannedCapacity.ToArray() : null,
|
|
ExpCategories = (t.ExpCategories != null) ? t.ExpCategories.Select(e => new ExpCategoryCapacity()
|
|
{
|
|
Id = e.Value.Id,
|
|
Name = e.Value.Name,
|
|
NeedCapacity = e.Value.NeedCapacity,
|
|
PlannedCapacityValues = e.Value.PlannedCapacityValues,
|
|
AllocatedCapacity = e.Value.AllocatedCapacity,
|
|
ActualCapacityValues = e.Value.ActualCapacityValues,
|
|
UomValue = e.Value.UomValue,
|
|
AllowResourceAssignment = e.Value.AllowResourceAssignment,
|
|
Resources = (e.Value.Resources != null) ? e.Value.Resources.Select(r => new ActivityResource()
|
|
{
|
|
Id = r.Value.Id,
|
|
AllocatedCapacity = r.Value.AllocatedCapacity,
|
|
TotalCapacity = r.Value.TotalCapacity,
|
|
}).ToDictionary(kk => kk.Id.ToString(), vv => vv) : null
|
|
}).ToDictionary(k => k.Id.ToString(), v => v) : null
|
|
}).ToList();
|
|
|
|
|
|
|
|
obj.Users = Users;
|
|
|
|
obj.ManagedProjects = new List<Guid>();
|
|
obj.UnscheduledProjects = new List<Guid>();
|
|
obj.QueuedProjects = new List<Guid>();
|
|
obj.UnassignedExpProjects = new List<CategoryExpenditureInMongoProject>();
|
|
obj.Layout = new List<MixTeamLayoutRowItem>();
|
|
|
|
obj.TeamsViews = Filter.Selection.TeamsViews.Select(x => new MixTeamView()
|
|
{
|
|
Id = x.Id,
|
|
IsNew = x.IsNew,
|
|
Name = x.TVName,
|
|
Group = x.Group.Name,
|
|
Data = x.Data,
|
|
CapacityTeamId = x.CapacityTeamId,
|
|
CompanyId = x.CompanyId,
|
|
CopyPlanned = x.CopyPlanned,
|
|
CostCenterId = x.CostCenterId,
|
|
UserId = x.UserId
|
|
}).ToList();
|
|
|
|
if (this.Calendar.ManagedProjects != null)
|
|
obj.ManagedProjects.AddRange(this.Calendar.ManagedProjects);
|
|
|
|
if (this.Calendar.UnscheduledProjects != null)
|
|
obj.UnscheduledProjects.AddRange(this.Calendar.UnscheduledProjects);
|
|
|
|
if (this.Calendar.QueuedProjects != null)
|
|
obj.QueuedProjects.AddRange(this.Calendar.QueuedProjects);
|
|
|
|
if (this.Calendar.UnassignedExpendituresProjects != null)
|
|
obj.UnassignedExpProjects = this.Calendar.UnassignedExpendituresProjects.Select(t =>
|
|
new CategoryExpenditureInMongoProject()
|
|
{
|
|
ProjectId = t.ProjectId,
|
|
ExpCatId = t.ExpCatId,
|
|
TargetTeamId = t.TargetTeamId,
|
|
Name = t.Name,
|
|
AllowResourceAssignment = t.AllowResourceAssignment
|
|
}).ToList();
|
|
|
|
|
|
if (Calendar.Projects != null)
|
|
{
|
|
obj.Projects = Calendar.Projects.Where(x => x.Value != null)
|
|
.Select(p => (new MixProject(p.Value)))
|
|
.ToDictionary(p => p.Id.ToString());
|
|
}
|
|
|
|
if (Calendar.Layout != null)
|
|
{
|
|
obj.Layout = this.Calendar.Layout.Select(l => new MixTeamLayoutRowItem()
|
|
{
|
|
TeamId = l.TeamId,
|
|
Row = l.Row,
|
|
Index = l.Index,
|
|
ProjectId = l.ProjectId
|
|
}).ToList();
|
|
}
|
|
}
|
|
}
|
|
} |