public bool UpdateReport(UpdateReportDto report, string reportGUID, User user) { var origReport = _reportRepository.Get(reportGUID); if (origReport == null) { throw new NotFoundException("Invalid reportGUID."); } var rel = _userReportRel.Get(origReport.Id, user.Id); if (rel == null || rel.AuthoryLayer != (int)ReportUserPermissions.CanModify) { throw new PermissionException("Don't have permission."); } origReport.Name = report.Name; origReport.ReportGUID = report.ReportGUID; origReport.Query = _reportRepository.GetQuery(report.QueryGUID); origReport.Columns = StringArraySerializer(report.Columns); origReport.Filter = report.Filter; origReport.Sort = JsonConvert.SerializeObject(report.Sort, Formatting.None); origReport.Rows = report.Rows; origReport.LastModifier = user; _reportRepository.Update(origReport); return(true); }
public IActionResult Update(int id) { var report = _reportService.GetReportWithTaskById(id); UpdateReportDto updateReportDto = new UpdateReportDto(); updateReportDto.ReportId = report.Id; updateReportDto.Definition = report.Description; updateReportDto.Detail = report.Detail; updateReportDto.Task = report.Task; updateReportDto.TaskId = report.TaskId; return(View(updateReportDto)); }
public IActionResult Update(UpdateReportDto model) { if (ModelState.IsValid) { Report report = _reportService.GetById(model.ReportId); report.Description = model.Definition; report.Detail = model.Detail; _reportService.Update(report); return(RedirectToAction("Index")); } return(View(model)); }
public IActionResult UpdateReport([FromBody] UpdateReportDto report, string reportGUID) { try { if (report == null) { throw new BasicException("Invalid input format!"); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } User user = _userRep.GetByEmailAdd(this.User.Claims.SingleOrDefault(x => x.Type == "EmailAddress").Value); _manager.UpdateReport(report, reportGUID, user); return(NoContent()); } catch (BasicException ex) { _logger.LogError(ex.Message); return(BadRequest(ex.Message)); } catch (NotFoundException ex) { _logger.LogError(ex.Message); return(NotFound(ex.Message)); } catch (PermissionException ex) { _logger.LogError(ex.Message); return(Unauthorized()); } catch (Exception ex) { _logger.LogError(ex.Message); return(BadRequest()); } }