Exemplo n.º 1
0
        public async Task <IActionResult> Add([FromBody] Clientes model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var Id = await clientesRepository.Add(model);

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

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

            return(BadRequest());
        }
Exemplo n.º 2
0
        public IActionResult Create([FromBody] Clientes cliente)
        {
            if (cliente == null)
            {
                return(BadRequest());
            }

            _userRepository.Add(cliente);

            return(Ok(new { id = cliente.id }));
        }
Exemplo n.º 3
0
        public object Post(Cliente cliente)
        {
            object json;
            string messageError = "";

            try
            {
                Cliente posted = repository.Add(cliente, ref messageError);

                if (posted != null)
                {
                    json = new
                    {
                        total   = 1,
                        data    = posted,
                        success = true
                    };
                }
                else
                {
                    json = new
                    {
                        message = messageError,
                        success = false
                    };
                };
            }
            catch (Exception ex)
            {
                LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message);

                object error = new { message = ex.Message };

                json = new
                {
                    message = ex.Message,
                    success = false
                };
            };

            return(json);
        }
Exemplo n.º 4
0
 public void AgregarCliente(Cliente cliente)
 {
     _clientesRepository.Add(cliente);
     _clientesRepository.Commit();
 }
 public Clientes Add(Clientes entity)
 {
     return(_clientesRepository.Add(entity));
 }