public IHttpActionResult Post([FromBody] Client client) { LogManager.AddInfo(DateTime.Now + $" BEGIN : ClientsController.Post Nombre:{client.Nombre}, Apellido:{client.Apellido}"); var result = new JsonResultModel <string>() { Success = false };; var stopWatch = GetStopWatch(); try { clientsService.Create(client); result.Success = true; LogManager.AddInfo(DateTime.Now + $" SUCCESS : ClientsController.Post Nombre:{client.Nombre}, Apellido:{client.Apellido}"); stopWatch.Stop(); } catch (Exception ex) { stopWatch.Stop(); LogManager.AddError("ClientsController", "Post", string.Empty, string.Empty, stopWatch.ElapsedTicks, ex); // result.Message = ex.Message; } return(Ok(result)); }
public async Task <ActionResult> Post([FromBody] ClientDto client) { if (string.IsNullOrEmpty(client.Name) || string.IsNullOrEmpty(client.Surname)) { throw new PreConditionFailedModelException(); } var id = await _clientsService.Create(client); return(Created($"/{ApiConstants.BaseUri}/{ApiConstants.ClientUri}/{id}", id)); }
public async Task <ActionResult> Post([FromBody] ClientDto client) { var id = await _clientsService.Create(client); return(Created($"/{ApiConstants.BaseUri}/{ApiConstants.IdParamUri}/{id}", id)); }
public async Task <IActionResult> Post(NewClientDto newClient) { var createdClient = await _clientsService.Create(newClient); return(Ok(createdClient)); }
public HttpResponseMessage Post([FromBody] ClientViewModel value) { return(ToJson(_clientsService.Create(Mapper.Map <ClientViewModel, Clients>(value)))); }