Abfrage bei Klick auf Neu oder Abbrechen beim Unterschriftenfeld und die Buttons sind normalgroß
165 lines
4.9 KiB
C#
165 lines
4.9 KiB
C#
using BeWoPlanerMobil.Models;
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace BeWoPlanerMobil.Util
|
|
{
|
|
|
|
public class DcToMokMapper
|
|
{
|
|
public static MokMandator CreateMandator(MandatorDC dc)
|
|
{
|
|
return new MokMandator
|
|
{
|
|
Settings = dc.Settings
|
|
};
|
|
|
|
}
|
|
|
|
public static MokZiel CreateZiel(ValueListEntryDC dc)
|
|
{
|
|
return new MokZiel
|
|
{
|
|
ValueListEntryOid = dc.ValueListEntryOid,
|
|
RatingTypeOid = dc.RatingTypeOid,
|
|
Type = dc.Type,
|
|
DisplayName = dc.DisplayName,
|
|
ParentOid = dc.ParentOid
|
|
};
|
|
|
|
}
|
|
|
|
public static IList<MokZiel> CreateZiele(IEnumerable<ValueListEntryDC> dclist)
|
|
{
|
|
return dclist?.Select(CreateZiel).ToList();
|
|
}
|
|
|
|
public static MokServiceRecord CreateServiceRecord(ServiceRecordDC dc, ReportModel model)
|
|
{
|
|
var s = new MokServiceRecord
|
|
{
|
|
Oid = dc.ServiceRecordOid.Value,
|
|
ServiceRecordType = dc.ServiceRecordType,
|
|
DistanceInMeter = dc.DistanceInMeter,
|
|
Start = dc.Start,
|
|
End = dc.End,
|
|
EmployeeName = dc.Employee.FirstNameLastName,
|
|
ServiceCategoryName = dc.ServiceDescription.CategoryName,
|
|
ServiceDescriptionName = dc.ServiceDescription.Name,
|
|
SignatureOid = dc.SignatureOid,
|
|
Notice = dc.Notice,
|
|
Notice2 = dc.Notice2,
|
|
Notice3 = dc.Notice3,
|
|
Notice4 = dc.Notice4,
|
|
Notice5 = dc.Notice5,
|
|
RoundedDuration = dc.RoundedDuration,
|
|
DistanceInMeterDecimal = dc.DistanceInMeterDecimal,
|
|
Betrag = dc.Betrag,
|
|
InsertedOn = dc.InsertedOn,
|
|
InsUser = dc.InsUser,
|
|
GroupOid = dc.GroupOid,
|
|
GroupPersonCount = dc.GroupPersonCount,
|
|
GroupEmployeeCount = dc.GroupEmployeeCount
|
|
};
|
|
|
|
if (s.Start.HasValue && s.End.HasValue)
|
|
{
|
|
s.HasSignatureString = s.SignatureOid.HasValue ? "JA" : "NEIN";
|
|
|
|
var start = s.Start.Value;
|
|
var end = s.End.Value;
|
|
|
|
var duration = (end - start).TotalMinutes;
|
|
|
|
var roundedDuration = MobileUtils.GetDecimalValueWithMaxDecimal(s.RoundedDuration, 2);
|
|
|
|
if (dc.ServiceDescription.Category.Percentage > 0 && dc.ServiceDescription.Category.Percentage < 100)
|
|
{
|
|
roundedDuration = roundedDuration * dc.ServiceDescription.Category.Percentage / 100;
|
|
}
|
|
|
|
s.DurationString = dc.GroupOid.HasValue ? string.Format("{0:###0.#} ({0:###0.#})", roundedDuration) : $"{duration:###0.#} ({roundedDuration:###0.#})";
|
|
|
|
s.MassnahmenString = string.Empty;
|
|
s.ZieleString = string.Empty;
|
|
|
|
if (dc.Goals != null && dc.Goals.Count > 0)
|
|
{
|
|
foreach (var goal in dc.Goals.Where(g => g.Type == ValueListEntryType.SupportConceptGoalType || g.Type == ValueListEntryType.SupportConceptIndividualGoalType))
|
|
{
|
|
if (goal.Abbreviation != null && goal.TypeDescription != null)
|
|
{
|
|
s.MassnahmenString += $"{goal.Abbreviation}: {goal.TypeDescription}";
|
|
}
|
|
else if (goal.Abbreviation is null && goal.TypeDescription != null)
|
|
{
|
|
s.MassnahmenString += goal.TypeDescription;
|
|
}
|
|
else if (goal.Abbreviation != null && goal.TypeDescription is null)
|
|
{
|
|
s.MassnahmenString += goal.Abbreviation;
|
|
}
|
|
|
|
#if DEBUG
|
|
if (model != null && goal.RatingTypeOid.HasValue)
|
|
{
|
|
var goalRating = model.GoalRatingTypes.FirstOrDefault(g => g.RatingTypeOid.HasValue && g.RatingTypeOid.Equals(goal.RatingTypeOid.Value));
|
|
|
|
if (goalRating?.DisplayName != null && goalRating.DisplayName.Length > 0)
|
|
{
|
|
s.MassnahmenString += $" <strong style='color: blue;'>({goalRating.DisplayName})</strong>";
|
|
}
|
|
}
|
|
#endif
|
|
|
|
if (dc.Goals.IndexOf(goal) < dc.Goals.Count - 1)
|
|
{
|
|
s.MassnahmenString += ", ";
|
|
}
|
|
}
|
|
|
|
if (model?.ServiceRecordOids2GoalHeader?.ContainsKey(s.Oid.Value) ?? false)
|
|
{
|
|
var ziele = dc.Goals.Where(g => g.Type == ValueListEntryType.SupportConceptIndividualGoalCategoryType || g.Type == ValueListEntryType.SupportConceptGoalCategoryType).ToList();
|
|
|
|
foreach (var ziel in ziele)
|
|
{
|
|
if (ziel.Abbreviation != null && ziel.TypeDescription != null)
|
|
{
|
|
s.ZieleString += $"{ziel.Abbreviation}: {ziel.TypeDescription} ";
|
|
}
|
|
else if (ziel.Abbreviation is null && ziel.TypeDescription != null)
|
|
{
|
|
s.ZieleString += ziel.TypeDescription;
|
|
}
|
|
else if (ziel.Abbreviation != null && ziel.TypeDescription is null)
|
|
{
|
|
s.ZieleString += ziel.Abbreviation;
|
|
}
|
|
|
|
#if DEBUG
|
|
if (ziel.RatingTypeOid.HasValue)
|
|
{
|
|
var zielbewertung = model.GoalRatingTypes.FirstOrDefault(goalRatingType => goalRatingType.RatingTypeOid.HasValue && goalRatingType.RatingTypeOid.Equals(ziel.RatingTypeOid.Value));
|
|
|
|
if (zielbewertung?.DisplayName != null && zielbewertung.DisplayName.Length > 0)
|
|
{
|
|
s.ZieleString += $" <strong style='color: blue;'>({zielbewertung.DisplayName})</strong>";
|
|
}
|
|
}
|
|
#endif
|
|
|
|
s.ZieleString += ", ";
|
|
}
|
|
}
|
|
|
|
s.ZieleString = s.ZieleString.TrimEnd(' ').TrimEnd(',');
|
|
}
|
|
}
|
|
|
|
return s;
|
|
}
|
|
}
|
|
} |