170 lines
6.9 KiB
C#
170 lines
6.9 KiB
C#
|
|
using Microsoft.AspNetCore.Mvc;
|
||
|
|
using PlanTempus.Application.Features.Localization.Services;
|
||
|
|
|
||
|
|
namespace PlanTempus.Application.Features.Customers.Components;
|
||
|
|
|
||
|
|
public class CustomerDetailOverviewViewComponent : ViewComponent
|
||
|
|
{
|
||
|
|
private readonly ILocalizationService _localization;
|
||
|
|
|
||
|
|
public CustomerDetailOverviewViewComponent(ILocalizationService localization)
|
||
|
|
{
|
||
|
|
_localization = localization;
|
||
|
|
}
|
||
|
|
|
||
|
|
public IViewComponentResult Invoke(string customerId)
|
||
|
|
{
|
||
|
|
var customer = CustomerDetailCatalog.Get(customerId);
|
||
|
|
|
||
|
|
var model = new CustomerDetailOverviewViewModel
|
||
|
|
{
|
||
|
|
// Contact
|
||
|
|
ContactTitle = _localization.Get("customers.detail.contactInfo"),
|
||
|
|
Phone = customer.Contact.Phone,
|
||
|
|
PhoneLabel = _localization.Get("customers.detail.phone"),
|
||
|
|
Email = customer.Contact.Email,
|
||
|
|
EmailLabel = _localization.Get("customers.detail.email"),
|
||
|
|
Address = customer.Contact.Address,
|
||
|
|
AddressLabel = _localization.Get("customers.detail.address"),
|
||
|
|
ZipCity = $"{customer.Contact.Zip} {customer.Contact.City}",
|
||
|
|
ZipCityLabel = _localization.Get("customers.detail.zipCity"),
|
||
|
|
|
||
|
|
// Profile
|
||
|
|
ProfileTitle = _localization.Get("customers.detail.profile"),
|
||
|
|
ProfileItems = customer.Profile.Select(p => new ProfileItemViewModel
|
||
|
|
{
|
||
|
|
Title = p.Title,
|
||
|
|
Value = p.Value
|
||
|
|
}).ToList(),
|
||
|
|
|
||
|
|
// Marketing
|
||
|
|
MarketingTitle = _localization.Get("customers.detail.marketing"),
|
||
|
|
EmailMarketingLabel = _localization.Get("customers.detail.emailMarketing"),
|
||
|
|
EmailOptIn = customer.Marketing.EmailOptIn,
|
||
|
|
SmsMarketingLabel = _localization.Get("customers.detail.smsMarketing"),
|
||
|
|
SmsOptIn = customer.Marketing.SmsOptIn,
|
||
|
|
YesLabel = _localization.Get("common.yes"),
|
||
|
|
NoLabel = _localization.Get("common.no"),
|
||
|
|
|
||
|
|
// Payment
|
||
|
|
PaymentTitle = _localization.Get("customers.detail.paymentSettings"),
|
||
|
|
RequirePrepaymentLabel = _localization.Get("customers.detail.requirePrepayment"),
|
||
|
|
RequirePrepaymentDesc = "Kunden skal betale fuldt beløb ved booking",
|
||
|
|
RequirePrepayment = customer.Payment.RequirePrepayment,
|
||
|
|
AllowPartialPaymentLabel = _localization.Get("customers.detail.allowPartialPayment"),
|
||
|
|
AllowPartialPaymentDesc = "Kunden kan vælge at betale et depositum",
|
||
|
|
AllowPartialPayment = customer.Payment.AllowPartialPayment,
|
||
|
|
|
||
|
|
// Preferences
|
||
|
|
PreferencesTitle = _localization.Get("customers.detail.preferences"),
|
||
|
|
PreferredHairdresser = customer.Preferences.PreferredHairdresser,
|
||
|
|
PreferredHairdresserLabel = _localization.Get("customers.detail.preferredHairdresser"),
|
||
|
|
PreferredDays = customer.Preferences.PreferredDays,
|
||
|
|
PreferredDaysLabel = _localization.Get("customers.detail.preferredDay"),
|
||
|
|
SpecialRequests = customer.Preferences.SpecialRequests,
|
||
|
|
SpecialRequestsLabel = _localization.Get("customers.detail.specialRequests"),
|
||
|
|
|
||
|
|
// Warnings
|
||
|
|
WarningsTitle = _localization.Get("customers.detail.warnings"),
|
||
|
|
Warnings = customer.Warnings.Select(w => new WarningItemViewModel
|
||
|
|
{
|
||
|
|
Title = w.Title,
|
||
|
|
Value = w.Value
|
||
|
|
}).ToList(),
|
||
|
|
|
||
|
|
// Group & Relations
|
||
|
|
GroupRelationsTitle = _localization.Get("customers.detail.groupAndRelations"),
|
||
|
|
GroupLabel = "Kundegruppe:",
|
||
|
|
GroupId = customer.Group.GroupId,
|
||
|
|
GroupName = customer.Group.GroupName,
|
||
|
|
Relations = customer.Relations.Select(r => new RelationItemViewModel
|
||
|
|
{
|
||
|
|
Id = r.Id,
|
||
|
|
Name = r.Name,
|
||
|
|
Initials = r.Initials,
|
||
|
|
Type = r.Type
|
||
|
|
}).ToList(),
|
||
|
|
AddRelationText = "Tilføj relation"
|
||
|
|
};
|
||
|
|
|
||
|
|
return View(model);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public class CustomerDetailOverviewViewModel
|
||
|
|
{
|
||
|
|
// Contact
|
||
|
|
public required string ContactTitle { get; init; }
|
||
|
|
public required string Phone { get; init; }
|
||
|
|
public required string PhoneLabel { get; init; }
|
||
|
|
public required string Email { get; init; }
|
||
|
|
public required string EmailLabel { get; init; }
|
||
|
|
public required string Address { get; init; }
|
||
|
|
public required string AddressLabel { get; init; }
|
||
|
|
public required string ZipCity { get; init; }
|
||
|
|
public required string ZipCityLabel { get; init; }
|
||
|
|
|
||
|
|
// Profile
|
||
|
|
public required string ProfileTitle { get; init; }
|
||
|
|
public List<ProfileItemViewModel> ProfileItems { get; init; } = new();
|
||
|
|
|
||
|
|
// Marketing
|
||
|
|
public required string MarketingTitle { get; init; }
|
||
|
|
public required string EmailMarketingLabel { get; init; }
|
||
|
|
public bool EmailOptIn { get; init; }
|
||
|
|
public required string SmsMarketingLabel { get; init; }
|
||
|
|
public bool SmsOptIn { get; init; }
|
||
|
|
public required string YesLabel { get; init; }
|
||
|
|
public required string NoLabel { get; init; }
|
||
|
|
|
||
|
|
// Payment
|
||
|
|
public required string PaymentTitle { get; init; }
|
||
|
|
public required string RequirePrepaymentLabel { get; init; }
|
||
|
|
public required string RequirePrepaymentDesc { get; init; }
|
||
|
|
public bool RequirePrepayment { get; init; }
|
||
|
|
public required string AllowPartialPaymentLabel { get; init; }
|
||
|
|
public required string AllowPartialPaymentDesc { get; init; }
|
||
|
|
public bool AllowPartialPayment { get; init; }
|
||
|
|
|
||
|
|
// Preferences
|
||
|
|
public required string PreferencesTitle { get; init; }
|
||
|
|
public required string PreferredHairdresser { get; init; }
|
||
|
|
public required string PreferredHairdresserLabel { get; init; }
|
||
|
|
public required string PreferredDays { get; init; }
|
||
|
|
public required string PreferredDaysLabel { get; init; }
|
||
|
|
public required string SpecialRequests { get; init; }
|
||
|
|
public required string SpecialRequestsLabel { get; init; }
|
||
|
|
|
||
|
|
// Warnings
|
||
|
|
public required string WarningsTitle { get; init; }
|
||
|
|
public List<WarningItemViewModel> Warnings { get; init; } = new();
|
||
|
|
|
||
|
|
// Group & Relations
|
||
|
|
public required string GroupRelationsTitle { get; init; }
|
||
|
|
public required string GroupLabel { get; init; }
|
||
|
|
public required string GroupId { get; init; }
|
||
|
|
public required string GroupName { get; init; }
|
||
|
|
public List<RelationItemViewModel> Relations { get; init; } = new();
|
||
|
|
public required string AddRelationText { get; init; }
|
||
|
|
}
|
||
|
|
|
||
|
|
public class ProfileItemViewModel
|
||
|
|
{
|
||
|
|
public required string Title { get; init; }
|
||
|
|
public required string Value { get; init; }
|
||
|
|
}
|
||
|
|
|
||
|
|
public class WarningItemViewModel
|
||
|
|
{
|
||
|
|
public required string Title { get; init; }
|
||
|
|
public required string Value { get; init; }
|
||
|
|
}
|
||
|
|
|
||
|
|
public class RelationItemViewModel
|
||
|
|
{
|
||
|
|
public required string Id { get; init; }
|
||
|
|
public required string Name { get; init; }
|
||
|
|
public required string Initials { get; init; }
|
||
|
|
public required string Type { get; init; }
|
||
|
|
}
|