示例#1
0
        public async Task <IHttpActionResult> PostSession(string moniker, SessionModel sessionModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var camp = await _codeCampService.GetCodeCamp(moniker);

                    if (camp != null)
                    {
                        var createdModel = await _sessionService.AddNewSessionToACodeCamp(moniker, sessionModel);

                        return(CreatedAtRoute("GetSession", new { moniker = moniker, id = createdModel.Id }, createdModel));
                    }
                }
            }
            catch (Exception exception)
            {
                Logger.Error(exception);
                return(InternalServerError(exception));
            }

            return(BadRequest(ModelState));
        }