Exemple #1
0
        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));
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        public async Task <ActionResult> Post([FromBody] ClientDto client)
        {
            var id = await _clientsService.Create(client);

            return(Created($"/{ApiConstants.BaseUri}/{ApiConstants.IdParamUri}/{id}", id));
        }
Exemple #4
0
        public async Task <IActionResult> Post(NewClientDto newClient)
        {
            var createdClient = await _clientsService.Create(newClient);

            return(Ok(createdClient));
        }
Exemple #5
0
 public HttpResponseMessage Post([FromBody] ClientViewModel value)
 {
     return(ToJson(_clientsService.Create(Mapper.Map <ClientViewModel, Clients>(value))));
 }