public async Task <IActionResult> AddReport([FromBody] ReportResource reportResource) { var currentEmail = HttpContext.GetUserEmail(); User user = await _userService.GetUser(currentEmail); return(new OkObjectResult(await _reportService.AddReport(reportResource, user))); }
public void AddReport(int id, string report_person, string reportdate, string phone, string content, string type, int pid) { Context.Response.ContentType = "application/json;charset=utf-8"; Context.Response.ContentEncoding = Encoding.GetEncoding("utf-8"); Context.Response.Write(reportService.AddReport(id, report_person, reportdate, phone, content, type, pid)); Context.Response.End(); }
public IActionResult AddReport([FromBody] ReportDTO reportDTO) { try { if (ModelState.IsValid) { ServiceResultDTO serviceResult = reportService.AddReport(reportDTO); if (serviceResult.IsValid == true) { return(Json("Отчет успешно добавлен")); } else { Log.Error(serviceResult.ErrorMessage); return(BadRequest(serviceResult.ErrorMessage)); } } else { return(BadRequest(ModelState)); } } catch (Exception ex) { Log.Error(ex.Message + reportDTO.GetValueString()); return(BadRequest("Произошла неизвестная ошибка")); } }
public IActionResult OnPost(Report Report, IFormFile reportimage, IFormFile reportfile, string username) { if (!ModelState.IsValid) { return(Page()); } _reportService.AddReport(Report, reportimage, reportfile, username); return(RedirectToPage("Index")); }
public IActionResult PostReport([FromBody] CreateReportDto report) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _reportService.AddReport(report); return(Ok()); }
private void SaveRemainingCasesToReport() { if (!reportService.IsReportExist(iterationsService.Current)) { reportService.AddReport(iterationsService.Current, TimeSpan.Zero, new ExaminationAnswerModel(), AnswerStatus.Stopped, examinationQuestions[iterationsService.Current].QuestionId); } while (IsNextTestCaseExist) { var iteration = iterationsService.NextIteration(); reportService.AddReport(iteration, TimeSpan.Zero, new ExaminationAnswerModel(), AnswerStatus.Stopped, examinationQuestions[iterationsService.Current].QuestionId); } }
public IActionResult OnPost(int id) { if (ModelState.IsValid) { Report report = new Report(); report.Reporter = userID; report.Reported = id; report.Message = Request.Form["Message"]; ReportStatus = "Your Report was sent"; _reportService.AddReport(report); return(RedirectToPage("DummyReportPage", new { ReportStatus })); } return(RedirectToPage("DummyReportPage", ReportStatus)); }
public async Task <IActionResult> AddReport(AddReportModel model) { var session = HttpContext.Session; var userId = session.GetString(CommonConstants.USER_SESSION); if (userId == null) { return(Unauthorized()); } var accessId = Convert.ToInt64(userId); var result = await reportService.AddReport(accessId, model); if (result == null) { return(BadRequest()); } return(Ok(result)); }
public async Task <IActionResult> AddReport([FromQuery] int visitId, [FromQuery] int reporterId) { var state = await _reportService.AddReport(new VisitReport { VisitId = visitId, ReporterId = reporterId }); if (!state.Success) { return(BadRequest(state.Error)); } return(Ok(new { Id = state.Source.Id, VisitId = state.Source.VisitId, ReporterId = state.Source.ReporterId })); }
private void SaveExecute() { try { if (Report.NumberOfHours==null || Report.NumberOfHours<=0) { MessageBox.Show("Number of hours must be greater than 0"); return; } List<vwReport> todaysReport = reportService.GetAllReportsOfEmployeeByDate(DateTime.Today, employeeLogedIn); double sumOfHours = 0; foreach (var rep in todaysReport) { if (rep.NumberOfHours!=null) { sumOfHours += (double)rep.NumberOfHours; } } if (Report.NumberOfHours>12 ||todaysReport.Count > 2 || sumOfHours>12) { MessageBox.Show("You are not allowed to add report.\nYou can add two reports in one day and " + "\ntheir sum of hours must be less than 12"); } reportService.AddReport(Report); view.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public async Task <bool> AddReport(Domain.DomainModel.Report report) { return(await _reportService.AddReport(report)); }
public async Task <IActionResult> AddReport([FromBody] ReportToAddDto reportToAdd) { await _reportService.AddReport(reportToAdd); return(Ok()); }
public ActionResultStatus AddReport(int postId, ReportTypes reportType) { return(reportService.AddReport(postId, reportType)); }
public ActionResult Edit(ReportModel model) { string action = Request["Submit"]; if (action == "cancel") { return(RedirectToAction("Index")); } var defaultFormat = Request[Constant.REPORT_CONFIG_DEFAULT_FORMAT]; var serviceUrl = Request[Constant.REPORT_CONFIG_SERVICE_URL]; var reportPath = Request[Constant.REPORT_CONFIG_REPORT_PATH]; var userName = Request[Constant.REPORT_CONFIG_USER_NAME]; var password = Request[Constant.REPORT_CONFIG_PASSWORD]; var domain = Request[Constant.REPORT_CONFIG_DOMAIN]; #region 数据验证 if (string.IsNullOrEmpty(model.Name)) { ModelState.AddModelError("Name", "请输入报表名称."); } if (string.IsNullOrEmpty(defaultFormat)) { ModelState.AddModelError(Constant.REPORT_CONFIG_DEFAULT_FORMAT, "请选择报表格式."); } if (string.IsNullOrEmpty(serviceUrl)) { ModelState.AddModelError(Constant.REPORT_CONFIG_SERVICE_URL, "请输入报表服务地址."); } if (string.IsNullOrEmpty(reportPath)) { ModelState.AddModelError(Constant.REPORT_CONFIG_REPORT_PATH, "请输入报表路径."); } if (string.IsNullOrEmpty(userName)) { ModelState.AddModelError(Constant.REPORT_CONFIG_USER_NAME, "请输入用户名."); } if (string.IsNullOrEmpty(password)) { ModelState.AddModelError(Constant.REPORT_CONFIG_PASSWORD, "请输入用户密码."); } if (string.IsNullOrEmpty(domain)) { ModelState.AddModelError(Constant.REPORT_CONFIG_DOMAIN, "请输入用户域."); } #endregion var configs = new NameValueCollection(); configs.Add(Constant.REPORT_CONFIG_DEFAULT_FORMAT, defaultFormat); configs.Add(Constant.REPORT_CONFIG_SERVICE_URL, serviceUrl); configs.Add(Constant.REPORT_CONFIG_REPORT_PATH, reportPath); configs.Add(Constant.REPORT_CONFIG_USER_NAME, userName); configs.Add(Constant.REPORT_CONFIG_PASSWORD, password); configs.Add(Constant.REPORT_CONFIG_DOMAIN, domain); if (ModelState.IsValid) { try { if (model.Id <= 0) { var reportId = ReportService.AddReport(model, configs); return(RedirectToAction("Edit", new { id = reportId })); } else { ReportService.UpdateReport(model, configs); return(RedirectToAction("Index")); } } catch (Exception ex) { ViewBag.Message = ex.Message; } } ViewData["ReportConfigs"] = configs; InitReportFormats(defaultFormat); return(View(model)); }