Rename reference to distinguish more correctly
This commit is contained in:
parent
1a003981ea
commit
adb2a718f8
1 changed files with 19 additions and 43 deletions
|
@ -43,7 +43,7 @@ public partial class OfficeCustomerOrderCreatePage : IDisposable
|
|||
[Inject] public ICountryPriceCatalogRepository PriceCatalog { get; set; }
|
||||
[Inject] public ICountryCustomerRepository CustomerRepo { get; set; }
|
||||
[Inject] public ICountryCustomerHistoryRepository HistoryRepo { get; set; }
|
||||
[Inject] public ICountryCustomerActivityRepository CustomerActivityRepo { get; set; }
|
||||
[Inject] public ICountryCustomerActivityRepository CountryActivityRepo { get; set; }
|
||||
[Inject] public ICountryUserInfoRepository UserRepo { get; set; }
|
||||
[Inject] public NavigationManager Navigator { get; set; }
|
||||
[Inject] public IUserInfoService UserInfoService { get; set; }
|
||||
|
@ -94,20 +94,20 @@ public partial class OfficeCustomerOrderCreatePage : IDisposable
|
|||
{
|
||||
Interceptor.RegisterEvent();
|
||||
Interceptor.RegisterBeforeSendEvent();
|
||||
|
||||
// get info for logged in user
|
||||
UserInfo = await UserInfoService.GetUserInfo();
|
||||
// setup edit context
|
||||
ActivityContext = new EditContext(Activity);
|
||||
ActivityContext.OnFieldChanged += HandleFieldChanged;
|
||||
ActivityContext.OnValidationStateChanged += ValidationChanged;
|
||||
|
||||
// fetch customer
|
||||
Company = await CustomerRepo.GetByCustomerId(CountryCode, CompanyId);
|
||||
Logger.LogDebug("OfficeOrderCreate => Customer => {}", JsonSerializer.Serialize(Company));
|
||||
|
||||
var today = $"{DateTime.Now:yyyy-MM-dd}";
|
||||
// construct today's workdate
|
||||
// Initialize date variable
|
||||
SelectedDate = DateTime.Now;
|
||||
var today = $"{SelectedDate:yyyy-MM-dd}";
|
||||
Activity.ActivityDate = today;
|
||||
|
||||
// initiate a sync to ensure up-to-date product history
|
||||
if (Company.HistorySync != today)
|
||||
{
|
||||
|
@ -118,7 +118,7 @@ public partial class OfficeCustomerOrderCreatePage : IDisposable
|
|||
CompanyInvoices = await HistoryRepo.GetInvoiceList(CountryCode, CompanyId);
|
||||
Logger.LogDebug("OfficeOrderCreate => Invoices => {}", JsonSerializer.Serialize(CompanyInvoices));
|
||||
// fetch activities
|
||||
CompanyActivities = await CustomerActivityRepo.GetActivityList(CompanyId);
|
||||
CompanyActivities = await CountryActivityRepo.GetActivityList(CompanyId);
|
||||
Logger.LogDebug("OfficeOrderCreate => Activities => {}", JsonSerializer.Serialize(CompanyActivities));
|
||||
// fetch inventory
|
||||
CompanyInventory = await HistoryRepo.GetInventory(CountryCode, CompanyId);
|
||||
|
@ -127,13 +127,11 @@ public partial class OfficeCustomerOrderCreatePage : IDisposable
|
|||
// get sales rep info
|
||||
SalesRep = await UserRepo.GetUserInfo(Company.SalesRepId);
|
||||
Logger.LogDebug("OfficeOrderCreate => SalesRep => {}", JsonSerializer.Serialize(SalesRep));
|
||||
|
||||
// set activity salesRep and countryCode
|
||||
// assign salesRep and countryCode to activity
|
||||
Activity.SalesRep = SalesRep.SalesRep;
|
||||
Activity.CountryCode = SalesRep.CountryCode;
|
||||
Activity.SalesRepId = Company.SalesRepId;
|
||||
|
||||
// add customer info into activity properties
|
||||
// assign customer info into activity properties
|
||||
Activity.Account = Company.Account;
|
||||
Activity.VatNumber = Company.VatNumber;
|
||||
Activity.Email = Company.Email;
|
||||
|
@ -151,15 +149,12 @@ public partial class OfficeCustomerOrderCreatePage : IDisposable
|
|||
Activity.DlvCity = Company.City;
|
||||
Activity.BcId = Company.BcId;
|
||||
Activity.CompanyId = Company.CompanyId;
|
||||
|
||||
// setting up activity properties
|
||||
// assign activity properties
|
||||
Activity.ActivityVisitEnum = "none";
|
||||
Activity.ActivityTypeEnum = "phone";
|
||||
Activity.ActivityStatusEnum = "order";
|
||||
Activity.OurRef = $"TLF:{UserInfo.FirstName}";
|
||||
|
||||
// Initialize date variable
|
||||
SelectedDate = DateTime.Now;
|
||||
Working = false;
|
||||
}
|
||||
|
||||
|
@ -286,13 +281,6 @@ public partial class OfficeCustomerOrderCreatePage : IDisposable
|
|||
|
||||
// reset selected item
|
||||
SelectedItem = new SalesItemView();
|
||||
// // check if phone number need to be updated
|
||||
// if (OldPhone != Activity.Phone)
|
||||
// {
|
||||
// Company.Phone = Activity.Phone;
|
||||
// Activity.OrderMessage = $"Telefonnr. opdateret.\n{Activity.OrderMessage}";
|
||||
// await CompanyRepo.UpdateErpData(Company.CompanyId, Company);
|
||||
// }
|
||||
|
||||
// begin assembling activity
|
||||
Activity.ActivityDate = $"{SelectedDate:yyyy-MM-dd}";
|
||||
|
@ -305,16 +293,18 @@ public partial class OfficeCustomerOrderCreatePage : IDisposable
|
|||
{
|
||||
var lines = DraftProvider.Draft.Items.Select(item => new ActivityLineDto
|
||||
{
|
||||
Price = item.Price,
|
||||
// sales properties
|
||||
Discount = item.Discount,
|
||||
LineAmount = item.LineTotal,
|
||||
Price = item.Price,
|
||||
Qty = item.Quantity,
|
||||
Sku = item.Item.Sku,
|
||||
Text = item.Item.Name,
|
||||
ShortName = item.Item.ShortName,
|
||||
LineAmount = item.LineTotal,
|
||||
LineNumber = ++ln,
|
||||
Sas = item.Sas,
|
||||
Location = item.Item.Location
|
||||
// item properties
|
||||
Location = item.Item.Location,
|
||||
ShortName = item.Item.ShortName,
|
||||
Sku = item.Item.Sku,
|
||||
Text = item.Item.Name,
|
||||
})
|
||||
.ToList();
|
||||
Activity.Lines = lines;
|
||||
|
@ -323,7 +313,7 @@ public partial class OfficeCustomerOrderCreatePage : IDisposable
|
|||
// debug logging
|
||||
Logger.LogDebug("CrmNewActivityPage => \n {}", JsonSerializer.Serialize(Activity));
|
||||
// post to api
|
||||
var result = await CustomerActivityRepo.PostPhoneOrder(Company.CompanyId, Activity);
|
||||
var result = await CountryActivityRepo.PostPhoneOrder(Company.CompanyId, Activity);
|
||||
// debug logging
|
||||
Logger.LogDebug("ApiResponseView => \n {}", JsonSerializer.Serialize(result));
|
||||
// show result message
|
||||
|
@ -335,7 +325,6 @@ public partial class OfficeCustomerOrderCreatePage : IDisposable
|
|||
Working = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// lower working flag
|
||||
Working = false;
|
||||
// show error message
|
||||
|
@ -348,22 +337,12 @@ public partial class OfficeCustomerOrderCreatePage : IDisposable
|
|||
StateHasChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Edit Context handle field change
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void HandleFieldChanged(object sender, FieldChangedEventArgs e)
|
||||
{
|
||||
PoFormInvalid = !ActivityContext.Validate();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Edit Context handle validation change
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void ValidationChanged(object sender, ValidationStateChangedEventArgs e)
|
||||
{
|
||||
PoFormInvalid = false;
|
||||
|
@ -374,9 +353,6 @@ public partial class OfficeCustomerOrderCreatePage : IDisposable
|
|||
ActivityContext.OnValidationStateChanged += ValidationChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implement Dispose from IDisposable
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Interceptor.DisposeEvent();
|
||||
|
|
Loading…
Reference in a new issue