public HttpResponseMessage SaveDenounce(Denounce Denuncia) { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); ResponseConfig config = VerifyAuthorization(Request.Headers); RestResponse data = new RestResponse(); try { VerifyMessage(config.errorMessage); using (DenounceService service = new DenounceService()) { service.saveDenounce(Denuncia.Denounces_id, Denuncia.Description, Denuncia.state, Denuncia.person_Id, Denuncia.User_id, Denuncia.Department_Id, Denuncia.Photo, Denuncia.Latitud.ToString(), Denuncia.Longitud.ToString()); data.result = null; data.status = true; data.message = Denuncia.Denounces_id == 0 ? "Se creó la Denuncia": "Se actualizó la Denuncia"; } } catch (Exception ex) { response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized; data.status = false; data.message = ex.Message; data.error = NewError(ex, "hubo un error"); } finally { response.Content = CreateContent(data); } return(response); }
public HttpResponseMessage UpdateDenouncebyAdmin([FromBody] Denounce Denuncia, string act) { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); ResponseConfig config = VerifyAuthorization(Request.Headers); RestResponse data = new RestResponse(); try { VerifyMessage(config.errorMessage); using (DenounceService service = new DenounceService()) { service.UpdateDenouncebyAdmin(Denuncia.Denounces_id, Denuncia.state, Denuncia.Department_Id, Denuncia.Answer, act); data.result = null; data.status = true; data.message = act == "R" ? "Se direccionó la denuncia Correctamente" : "Se le ha dado una respuesta a la denuncia correctamente"; } } catch (Exception ex) { response.StatusCode = config.isAuthenticated ? HttpStatusCode.BadRequest : HttpStatusCode.Unauthorized; data.status = false; data.message = ex.Message; data.error = NewError(ex, "hubo un error"); } finally { response.Content = CreateContent(data); } return(response); }
public ActionResult CreateDenounce(Denounce denounce) { var memoryStream = new MemoryStream(); denounce.LogoFile.InputStream.CopyTo(memoryStream); string tweetText; if (!denounce.FakeNewsURL.IsNullOrEmpty() && Uri.IsWellFormedUriString(denounce.FakeNewsURL, UriKind.Absolute)) { if (denounce.TweetText.IndexOf("@slpng_giants_pt") != -1) { tweetText = denounce.TweetText.Replace("@slpng_giants_pt", "") + denounce.FakeNewsURL.Trim() + " @slpng_giants_pt"; } else { tweetText = denounce.TweetText + denounce.FakeNewsURL.Trim(); } } else { tweetText = denounce.TweetText ?? ""; } var success = TwitterIntegrationService.GetInstance().PostMediaTweet(memoryStream, tweetText); if (!success) { success = TwitterIntegrationService.GetInstance().PostMediaTweet(memoryStream, denounce.TweetText); } if (success) { new DatabaseService().IncrementDenounce(); } TempData["posted"] = success ? "success" : "fail"; return(RedirectToAction("Index", "Home")); }