public virtual IActionResult PeoplewithwearablesPersonIdSendMediaMessagePost([FromRoute][Required] string personId, [FromBody] MediaMessage message, [FromHeader][Required()] string Authorization) { //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... // return StatusCode(200, default(GeneralResponse)); //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... // return StatusCode(0, default(ErrorResponse)); if (!ModelState.IsValid) { var error = ModelState.SelectMany(x => x.Value.Errors).First(); if (error.ErrorMessage != null && error.ErrorMessage != String.Empty) { return(BadRequest(error.ErrorMessage)); } else if (error.Exception?.Message != null) { return(BadRequest("Faulty input")); } else { return(BadRequest(ModelState)); } } if (Authorization != settings.testToken) { return(BadRequest("Not allowed")); } long newZoneID = 0; string errorMessage = ""; PersonWithWearable result = null; try { DatabaseInterface.DBPersonWithWearablesApi dBPersonWithWearablesApi = new DatabaseInterface.DBPersonWithWearablesApi(); if (!dBPersonWithWearablesApi.DBSendPersonMediaMessage(personId, message.MediaLink, message.MediaType, ref errorMessage)) { return(BadRequest("Internal Server Error:" + errorMessage)); } } catch (Exception e) { return(BadRequest("Internal Server Error:" + e.Message)); } string exampleJson = null; exampleJson = "{\n \"success\" : true,\n \"description\" : \"Message sent\"\n}"; var example = exampleJson != null ? JsonConvert.DeserializeObject <GeneralResponse>(exampleJson) : default(GeneralResponse); //TODO: Change the data returned return(new ObjectResult(example)); }
public virtual IActionResult PeoplewithwearablesGet([FromQuery] string role, [FromHeader][Required()] string Authorization) { if (!ModelState.IsValid) { var error = ModelState.SelectMany(x => x.Value.Errors).First(); if (error.ErrorMessage != null && error.ErrorMessage != String.Empty) { return(BadRequest(error.ErrorMessage)); } else if (error.Exception?.Message != null) { return(BadRequest("Faulty input")); } else { return(BadRequest(ModelState)); } } if (Authorization != settings.testToken) { return(BadRequest("Not allowed")); } long newZoneID = 0; string errorMessage = ""; List <PersonWithWearable> results = new List <PersonWithWearable>(); try { DatabaseInterface.DBPersonWithWearablesApi dBPersonWithWearablesApi = new DatabaseInterface.DBPersonWithWearablesApi(); if (!dBPersonWithWearablesApi.ListPersonWithWearables(role, ref errorMessage, ref results)) { return(BadRequest("Internal Server Error:" + errorMessage)); } } catch (Exception e) { return(BadRequest("Internal Server Error:" + e.Message)); } string exampleJson = null; return(new ObjectResult(results)); }