Пример #1
0
        public async Task <IActionResult> Add([FromBody] Conta model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var Id = await contasRepository.Add(model);

                    if (Id > 0)
                    {
                        var result = new
                        {
                            code = 20000,
                            data = new
                            {
                                id     = Id,
                                mesage = "success"
                            }
                        };

                        return(Ok(result));
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
                catch (Exception)
                {
                    return(BadRequest());
                }
            }

            return(BadRequest());
        }
Пример #2
0
        public void Add(ContasViewModel contas)
        {
            Contas mapContas = _mapper.Map <Contas>(contas);

            _contasRepository.Add(mapContas);
        }