コード例 #1
0
        public async Task <IActionResult> CreatePhotographer(CreatePhotographer photographer)
        {
            Logger.Log(LogLevel.Information, "POST: on CreatePhotographer");

            // automatically returns 400 when validation or binding fails but for logging we do it explicitly
            if (!ModelState.IsValid)
            {
                Logger.Log(LogLevel.Information, "CREATE: Photographer with %s, failed!", new { photographer });
                return(BadRequest());
            }

            var inserted = await _picDb.CreatePhotographer(new Photographer
            {
                FirstName = photographer.FirstName,
                LastName  = photographer.LastName,
                Birthday  = photographer.Birthday.Date,
                Notes     = photographer.Notes
            });

            return(Ok(inserted));
        }