コード例 #1
0
 public async Task <ActionResult> CreateAsync([FromForm] string name)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest());
     }
     if (name == null)
     {
         return(BadRequest());
     }
     if (name.Length < 1)
     {
         try
         {
             return(await GetAllAsync());
         }
         catch (Exception ex)
         {
             logger.LogError(ex, "An error occurred");
             return(StatusCode(StatusCodes.Status500InternalServerError));
         }
     }
     try
     {
         createInteractor.CreateSomething(name);
         return(await GetAllAsync());
     }
     catch (Exception ex)
     {
         logger.LogError(ex, "An error occurred");
         return(StatusCode(StatusCodes.Status500InternalServerError));
     }
 }
コード例 #2
0
        public ActionResult Create([FromForm] string name)
        {
            if (name.Length < 1)
            {
                return(GetAll());
            }

            createInteractor.CreateSomething(name);
            return(GetAll());
        }
コード例 #3
0
        public async Task <ActionResult> CreateAsync([FromForm] string name)
        {
            if (name.Length < 1)
            {
                return(await GetAllAsync());
            }

            createInteractor.CreateSomething(name);
            return(await GetAllAsync());
        }