コード例 #1
0
 public IActionResult CreateNewContact_WithCard([FromBody] ContactWithCard_ViewModel newContactWithCard)
 {
     try
     {
         if (ModelState.IsValid)//checking model state
         {
             var contactWithCard_CreationResult = ContactsRepo.CreateNewContactWithCard(newContactWithCard);
             if (contactWithCard_CreationResult.GetType() == typeof(ContactWithCard_Created_ViewModel))
             {
                 return(Ok(contactWithCard_CreationResult)); //if the creation is successful return the id of the new contact as well as the id of the new card...
             }
             return(BadRequest());                           //if not... return bad request...
         }
         return(BadRequest(ModelState));                     //if model state is not valid
     }
     catch (Exception e)
     {
         return(StatusCode(500, _config["StatusCodesText:ServerErr"]));
     }
 }