// POST: api/WebApiClient public IHttpActionResult Post([FromBody] ClientApiViewModel CVM) { if (!ModelState.IsValid) { return(BadRequest("Invalid data.")); } Client C = new Client(); C.Clientid = CVM.ClientID; C.Nom = CVM.Nom; C.Prenom = CVM.Prenom; C.Email = CVM.Email; C.PhoneNumber = CVM.NumeroTel; CS.Add(C); CS.Commit(); return(Ok(C)); }
public ActionResult <string> Post([FromBody] ClientRequestViewModel client) { try { _logger.LogInformation("Add a new client"); var result = _clientServices.Add(client); if (result.ValidationResult.Errors.Any()) { return(AddValidationErrors(result.ValidationResult.Errors)); } return(Ok(result)); } catch (Exception ex) { _logger.LogError(ex, ex.Message); return(new StatusCodeResult(500)); } }
public ActionResult <Guid> Post([FromBody] Client client) { try { Guid key = _clientServices.Add(client); if (client.Invalid) { return(BadRequest(new { notifications = client.GetNotification() })); } return(Ok(new { key = key })); } catch (Exception exception) { _logger.LogError(exception, exception.Message); return(new StatusCodeResult(500)); } }
public IHttpActionResult Add([FromBody] ClientVM oClientVM) { try { if (!ModelState.IsValid) { return(BadRequest()); } var oStaffProfile = _clientService.Add(oClientVM); if (oStaffProfile >= 1) { return(Ok(oClientVM)); } return(BadRequest("Sever could not fulfil request")); } catch (Exception ex) { LogHelper.Log(ex); return(InternalServerError(ex)); } }