Ejemplo n.º 1
0
 public static void ValidateSaveRequest(PhonebookRecordSaveRequestClientData clientData)
 {
     if (!clientData.Id.HasValue && string.IsNullOrWhiteSpace(clientData.Fullname))
     {
         throw new ArgumentException("Empty name is not allowed");
     }
 }
Ejemplo n.º 2
0
        public async Task <int> Save([FromBody] PhonebookRecordSaveRequestClientData clientData)
        {
            PhonebookValidator.ValidateSaveRequest(clientData);

            var saveRequest = PhonebookRecordMapper.MapToSaveRequest(clientData);
            var result      = await service.SaveAsync(saveRequest).ConfigureAwait(false);

            return(result);
        }
Ejemplo n.º 3
0
 public static PhonebookRecordSaveRequest MapToSaveRequest(PhonebookRecordSaveRequestClientData clientData)
 {
     return(new PhonebookRecordSaveRequest
     {
         Id = clientData.Id,
         Fullname = clientData.Fullname,
         PhoneNumbers = clientData.PhoneNumbers?.Select(x => x).ToList() ?? new List <string>()
     });
 }