Exemple #1
0
        public IHttpActionResult PostProposal(ProposalDTO dtoProposal)
        {
            var client = _clientService.GetClient(dtoProposal.Email);

            var proposal = Mapper.Map <Proposal>(dtoProposal);

            proposal.ClientID = client.ID;
            _proposalService.CreateProposal(proposal);

            try
            {
                _proposalService.SaveProposal();
            }
            catch (DbUpdateException)
            {
                if (!_proposalService.ProposalExists(proposal.ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }
            return(CreatedAtRoute("DefaultApi", new { id = dtoProposal.ID }, dtoProposal));
        }