public async Task <bool> CreateAsync(object request) { ReportDisasterRequest request_ = (ReportDisasterRequest)request; ClassValueCopier copier = new ClassValueCopier(); ReportedDisaster newReport = copier.ConvertAndCopy <ReportedDisaster, ReportDisasterRequest>(request_); newReport.CreatedBy = request_.ReportedBy; newReport.IsVerfied = false; bool result = await _disasterCollection.AddAsync(newReport); if (result) { //Implemented:: //create the message VerifyDisasterRequest verifyDisaster = copier.ConvertAndCopy <VerifyDisasterRequest, ReportedDisaster>(newReport); string data = JsonConvert.SerializeObject(verifyDisaster); //publishing the message await Mqtt.MqttPublish("RSCD/Server/Disaster/Verification", data); //return the http response //TO DO:: //1.create the message //2.push to the queue //3.return the http response } return(result); }
public async Task <IActionResult> ReportDisaster(ReportDisasterRequest request) { ActionResponse response; try { bool result = await _businessLogic.CreateAsync(request); response = new ActionResponse((result) ? StatusCodes.Status200OK : StatusCodes.Status422UnprocessableEntity); } catch (Exception ex) { response = new ActionResponse(StatusCodes.Status500InternalServerError); response.StatusDescription += ex.Message.ToString(); } return(StatusCode(response.StatusCode, response)); }