public async Task <bool> ReportWrongAdvertisement(int advertId, string reason) { var model = new WrongAdvertisementIssueModel(); model.Reason = reason; model.AdvertisementId = advertId; var stringContent = new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json"); HttpResponseMessage response; try { response = await client.PostAsync(WebApiConsts.FEEDBACK_CONTROLLER + "ReportWrongAdvertisement/", stringContent); } catch { response = new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError); } if (response.StatusCode != System.Net.HttpStatusCode.OK) { return(false); } return(true); }
public bool ReportWrongAdvertisement(string userId, WrongAdvertisementIssueModel model) { var issue = new WrongAdvertisementIssue(); issue.IssueAuthorId = userId; issue.Reason = model.Reason; issue.AdvertisementId = model.AdvertisementId; feedbackDbService.SaveWrongAdvertisementIssue(issue); this.emailService.ReportWrongAdvertisementIssue(model); return(true); }
public IActionResult ReportWrongAdvertisement([FromBody] WrongAdvertisementIssueModel model) { try { var userId = this.identityService.GetUserId(User.Identity); bool result = this.feedbackService.ReportWrongAdvertisement(userId, model); return(Json("ok")); } catch (Exception exc) { Response.StatusCode = (int)HttpStatusCode.InternalServerError; logger.LogError("Wyst¹pi³ wyj¹tek w trakcie zg³aszania og³oszenia naruszaj¹cego regulamin: " + exc); return(Json("Wyst¹pi³ b³¹d! - " + exc.Message)); } }
public void ReportWrongAdvertisementIssue(WrongAdvertisementIssueModel issueModel) { var mesageContent = String.Format("Ogłoszenie o id: {0} narusza regulamin. Powód: {1}", issueModel.AdvertisementId, issueModel.Reason); mailSender.Send("*****@*****.**", "*****@*****.**", "Ogłoszenie naruszające regulamin", mesageContent); }