public ActionResult GeneraReport(int Id, string Year, string Month, string Note) { RptHouseManagementManager ObjRptHouseManagementManager = new RptHouseManagementManager(); NewReportInputDto ObjNewReportInputDto = new NewReportInputDto(); ObjNewReportInputDto.year = Year; ObjNewReportInputDto.month = Month; ObjNewReportInputDto.notes = Note; IndexViewModel vm = InitializeIndexView(); try { ObjRptHouseManagementManager.NewReport(ObjNewReportInputDto, Id); //throw new Exception("errore colossale"); return(RedirectToAction("Index")); } catch (Exception ex) { return(RedirectToAction("Index", "Errore", new { @Errore = ex.Message })); } //valorizza // return View("Index",vm); }
public void NewReport(NewReportInputDto ObjNewReportInputDto, int IdHouse) { var myContent = JsonConvert.SerializeObject(ObjNewReportInputDto); //var buffer = System.Text.Encoding.UTF8.GetBytes(myContent); var buffer = System.Text.Encoding.UTF8.GetBytes(ObjNewReportInputDto.notes); var byteContent = new ByteArrayContent(buffer); byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); ///houses/{houseId}/reports/years/{year}/months/{month} var result = client.PostAsync("houses/" + IdHouse + "/reports/years/" + ObjNewReportInputDto.year + "/months/" + ObjNewReportInputDto.month, byteContent).Result; if (!result.IsSuccessStatusCode) { throw new Exception("An error occurred during creation of the report."); } }