コード例 #1
0
        public IActionResult Create([FromBody] NewIdeaModel model)
        {
            if (!ModelState.IsValid)
            {
                return(HttpBadRequest(ModelState));
            }
            var session = _sessionRepository.GetById(model.SessionId);

            if (session == null)
            {
                return(HttpNotFound(model.SessionId));
            }
            var idea = new Idea()
            {
                DateCreated = DateTimeOffset.Now,
                Description = model.Description,
                Name        = model.Name
            };

            session.AddIdea(idea);
            _sessionRepository.Update(session);
            return(Ok(session));
        }