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()); }
public IActionResult Create([FromBody] Clientes cliente) { if (cliente == null) { return(BadRequest()); } _userRepository.Add(cliente); return(Ok(new { id = cliente.id })); }
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); }
public void AgregarCliente(Cliente cliente) { _clientesRepository.Add(cliente); _clientesRepository.Commit(); }
public Clientes Add(Clientes entity) { return(_clientesRepository.Add(entity)); }