コード例 #1
0
        public async Task <IHttpActionResult> Delete(string moniker, int talkId)
        {
            try
            {
                Talk talk = await _repository.GetTalkByMonikerAsync(moniker, talkId, true);

                if (talk == null)
                {
                    return(NotFound());
                }

                _repository.DeleteTalk(talk);

                if (await _repository.SaveChangesAsync())
                {
                    //return Ok();
                    return(StatusCode(HttpStatusCode.NoContent));
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }

            return(InternalServerError());
        }
コード例 #2
0
        public async Task <IHttpActionResult> Delete(string moniker, int talkId)
        {
            try
            {
                var talk = await _repository.GetTalkByMonikerAsync(moniker, talkId);

                if (talk == null)
                {
                    return(NotFound());
                }

                _repository.DeleteTalk(talk);

                if (await _repository.SaveChangesAsync())
                {
                    return(Ok());
                }
                else
                {
                    return(InternalServerError());
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
コード例 #3
0
        public async Task <IHttpActionResult> Delete(string moniker, int talkId)
        {
            try
            {
                //if (ModelState.IsValid)
                {
                    var talko = await cr.GetTalkByMonikerAsync(moniker, talkId);

                    if (null == talko)
                    {
                        return(NotFound());
                    }
                    else
                    {
                        cr.DeleteTalk(talko);
                        return(Ok());
                    }
                }
            }
            catch (Exception e)
            {
                return(InternalServerError());
            }
            return(BadRequest());
        }
コード例 #4
0
        public async Task <IHttpActionResult> Put(string moniker, int talkId)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var talk = await _campsRepository.GetTalkByMonikerAsync(moniker, talkId);

                    if (talk == null)
                    {
                        return(NotFound());
                    }

                    //Mapping
                    _campsRepository.DeleteTalk(talk);
                    if (await _campsRepository.SaveChangesAsync())
                    {
                        return(Ok());
                    }
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
            return(BadRequest(ModelState));
        }
コード例 #5
0
        public async Task <IHttpActionResult> DeleteTalk(string moniker, int talkId)
        {
            var talk = await _db.GetTalkByMonikerAsync(moniker, talkId);

            if (talk == null)
            {
                return(NotFound());
            }

            _db.DeleteTalk(talk);

            await _db.SaveChangesAsync();

            return(Ok());
        }
コード例 #6
0
        public async Task <IHttpActionResult> DeleteTalk(string moniker, int id)
        {
            try
            {
                var talk = await _repository.GetTalkByMonikerAsync(moniker, id);

                _repository.DeleteTalk(talk);

                if (await _repository.SaveChangesAsync())
                {
                    return(Ok());
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }

            return(BadRequest());
        }