示例#1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="context"></param>
 /// <param name="model"></param>
 public ApiResponse <bool> CreatePerson(TestProjectDbContext context, PersonViewModel model)
 {
     try
     {
         Person person = new Person
         {
             Id          = Guid.NewGuid(),
             FirstName   = model.FirstName,
             LastName    = model.LastName,
             Deleted     = false,
             Identifiers = model.Identifiers.Select(x => new Identifier
             {
                 Id    = Guid.NewGuid(),
                 Type  = x.Type,
                 Value = x.Value
             }).ToList()
         };
         _repository.CreatePerson(context, person);
         return(ApiResponse <bool> .SuccessResult(true));
     }
     catch (Exception ex) when(ex is FailException || ex is ValidationException || ex is ArgumentException)
     {
         return(ApiResponse <bool> .ErrorResult(message : ex.Message, statusCode : HttpStatusCode.BadRequest));
     }
     catch (Exception ex) when(ex is ErrorException)
     {
         //LoggingManager.Error(ex.ToString());
         return(ApiResponse <bool> .ErrorResult(message : ex.Message));
     }
     catch (Exception ex)
     {
         //LoggingManager.Error(ex.ToString());
         return(ApiResponse <bool> .ErrorResult(message : ex.Message));
     }
 }