示例#1
0
        public async Task <ActionResult <DtoWhistle> > Get(int whistleID)
        {
            try
            {
                var result = await _repository.GetWhistle(whistleID);

                return(_mapper.Map <DtoWhistle>(result));
            }
            catch
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, ""));
            }
        }
示例#2
0
        public async Task <ActionResult <DtoConversation> > Post(DtoConversation ConversationInput)
        {
            try
            {
                var oldWhistle = await _repository.GetWhistle(ConversationInput.WhistleID);

                if (ConversationInput.Sender == Sender.Lawyer)
                {
                    oldWhistle.LastSender = 0;
                }
                else
                {
                    oldWhistle.LastSender = 1;
                }

                Conversation C = _mapper.Map <Conversation>(ConversationInput);
                _repository.Add(C);
                if (await _repository.SaveChangesAsync())
                {
                    return(Created($"/api/conversation/", _mapper.Map <DtoConversation>(C)));
                }
            }
            catch
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, ""));
            }
            return(BadRequest());
        }