/// <summary> /// Called before action runs. /// </summary> /// <remarks>Used to normalize all phone numbers to E164 format.</remarks> public static Task <string> ControllerPreprocessActionAsync(string propName, string model, ModelStateDictionary modelState) { if (!string.IsNullOrWhiteSpace(model)) { string number = PhoneNumberAttribute.GetE164(model); if (!string.IsNullOrWhiteSpace(number)) { model = number; } else { modelState.AddModelError(propName, __ResStr("invPhone", "{0} is an invalid phone number", model)); } } return(Task.FromResult(model)); }
public async Task <bool> AddItemAsync(BlockedNumberEntry data) { data.Created = DateTime.UtcNow; data.Number = PhoneNumberAttribute.GetE164(data.Number); if (!await DataProvider.AddAsync(data)) { return(false); } await Auditing.AddAuditAsync($"{nameof(BlockedNumberDataProvider)}.{nameof(AddItemAsync)}", Dataset, Guid.Empty, $"Add Blocked Number {data.Id}", DataBefore : null, DataAfter : data ); return(true); }
public async Task <UpdateStatusEnum> UpdateItemAsync(BlockedNumberEntry data) { BlockedNumberEntry origData = Auditing.Active ? await GetItemByIdentityAsync(data.Id) : null; data.Updated = DateTime.UtcNow; data.Number = PhoneNumberAttribute.GetE164(data.Number); UpdateStatusEnum status = await DataProvider.UpdateByIdentityAsync(data.Id, data); if (status != UpdateStatusEnum.OK) { return(status); } await Auditing.AddAuditAsync($"{nameof(BlockedNumberDataProvider)}.{nameof(UpdateItemAsync)}", Dataset, Guid.Empty, $"Update Blocked Number {data.Id}", DataBefore : origData, DataAfter : data ); return(UpdateStatusEnum.OK); }
// LOAD/SAVE // LOAD/SAVE // LOAD/SAVE public Task <BlockedNumberEntry> GetItemAsync(string number) { number = PhoneNumberAttribute.GetE164(number); return(DataProvider.GetAsync(number, null)); }