This commit is contained in:
2021-03-02 00:27:58 +00:00
parent 2a1713aadc
commit 7c1c946449
2 changed files with 32 additions and 5 deletions

View File

@@ -388,11 +388,11 @@ namespace AyaNova.Biz
//Fields not sent with the put object
//(it's only location is in the db and since this putObject is replacing the dbObject we need to set it again here)
putObject.Salt = dbObject.Salt;
putObject.CurrentAuthToken=dbObject.CurrentAuthToken;
putObject.DlKey=dbObject.DlKey;
putObject.DlKeyExpire=dbObject.DlKeyExpire;
putObject.PasswordResetCode=dbObject.PasswordResetCode;
putObject.PasswordResetCodeExpire=dbObject.PasswordResetCodeExpire;
putObject.CurrentAuthToken = dbObject.CurrentAuthToken;
putObject.DlKey = dbObject.DlKey;
putObject.DlKeyExpire = dbObject.DlKeyExpire;
putObject.PasswordResetCode = dbObject.PasswordResetCode;
putObject.PasswordResetCodeExpire = dbObject.PasswordResetCodeExpire;
//NOTE: It's valid to call this without intending to change login or password (null values)
@@ -878,9 +878,15 @@ namespace AyaNova.Biz
var batchResults = await ct.User.AsNoTracking().Include(z => z.UserOptions).Where(z => batch.Contains(z.Id)).ToArrayAsync();
//order the results back into original
var orderedList = from id in batch join z in batchResults on id equals z.Id select z;
//cache frequent viz data
//usertypes
var UserTypesEnumList = await AyaNova.Api.Controllers.EnumListController.GetEnumList(StringUtil.TrimTypeName(typeof(UserType).ToString()), UserTranslationId);
//foreach (User w in orderedList)
foreach (var w in orderedList)
{
await PopulateVizFields(w, UserTypesEnumList);
var jo = JObject.FromObject(w);
if (!JsonUtil.JTokenIsNullOrEmpty(jo["CustomFields"]))
jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]);
@@ -894,7 +900,20 @@ namespace AyaNova.Biz
return ReportData;
}
//populate viz fields from provided object
private async Task PopulateVizFields(User o, List<NameIdItem> userTypesEnumList)
{
if (o.CustomerId != null)
o.CustomerViz = await ct.Customer.AsNoTracking().Where(x => x.Id == o.CustomerId).Select(x => x.Name).FirstOrDefaultAsync();
if (o.HeadOfficeId != null)
o.HeadOfficeViz = await ct.HeadOffice.AsNoTracking().Where(x => x.Id == o.HeadOfficeId).Select(x => x.Name).FirstOrDefaultAsync();
if (o.VendorId != null)
o.VendorViz = await ct.Customer.AsNoTracking().Where(x => x.Id == o.VendorId).Select(x => x.Name).FirstOrDefaultAsync();
o.UserTypeViz = userTypesEnumList.Where(x => x.Id == (long)o.UserType).Select(x => x.Name).First();
}
////////////////////////////////////////////////////////////////////////////////////////////////
// IMPORT EXPORT

View File

@@ -63,12 +63,20 @@ namespace AyaNova.Models
public AuthorizationRoles Roles { get; set; }
[Required]
public UserType UserType { get; set; }
[NotMapped]
public string UserTypeViz { get; set; }
[MaxLength(255)]
public string EmployeeNumber { get; set; }
public string Notes { get; set; }
public long? CustomerId { get; set; }
[NotMapped]
public string CustomerViz { get; set; }
public long? HeadOfficeId { get; set; }
[NotMapped]
public string HeadOfficeViz { get; set; }
public long? VendorId { get; set; }
[NotMapped]
public string VendorViz { get; set; }
public string Wiki { get; set; }
public string CustomFields { get; set; }
public List<string> Tags { get; set; }