Пример #1
0
        public async Task <IActionResult> postVisitors([FromBody] VisitorList visitors)
        {
            try
            {
                if (visitors == null)
                {
                    Logger.LogError("The visitor List is null.");
                    return(BadRequest("Null visitor list"));
                }

                VisitorRepository.AddVisitors(visitors);
                await VisitorRepository.saveChanges();
            }
            catch (Exception exception)
            {
                Logger.LogError($"Something went wrong internally in the server: ", exception.Message);
                return(StatusCode(500, "Internal server error"));
            }

            return(Ok("Visitor List has been added to the database"));
        }