示例#1
0
        public async Task <ResponseHistoricoAddModel> Add(HistoricoAddModel model)
        {
            // TODO: Validation: (CPF e Id não podem ser repetidos)

            try
            {
                var historicoEntity = _mapper.Map <HistoricoEntity>(model);

                var historicoEntityDb = await _historicoRepository.Insert(historicoEntity);

                _uow.SaveChanges();

                return(new ResponseHistoricoAddModel {
                    Historico = _mapper.Map <HistoricoModel>((HistoricoEntity)historicoEntityDb.Entity), Message = "Historico Registrada com Sucesso", Success = true
                });
            }
            catch (Exception ex)
            {
                return(new ResponseHistoricoAddModel {
                    Historico = null, Message = ex.Message, Success = false
                });
            }
        }