public async Task <IActionResult> CreateReport() { if (hospitalId != null && roleName == "Hospital") { try { var patients = await _patientService.GetPatientsForHospital(hospitalId); var createReportModel = new CreateReportViewModel { HospitalId = hospitalId }; foreach (var patient in patients) { createReportModel.PatientsList.Add(new CreateReportPatientList { Id = patient.Id, Username = patient.User.Username }); } return(View(createReportModel)); } catch { ViewBag.ErrorLoadingPatients = true; return(View()); } } ViewBag.ErrorAuthorize = true; return(RedirectToAction("Index", "Home")); }
public async Task <IActionResult> CreateReport(CreateReportViewModel createReportViewModel) { if (!ModelState.IsValid) { return(View(createReportViewModel)); } try { ReportCreationResources reportCreationResources = new ReportCreationResources { HospitalId = createReportViewModel.HospitalId, Description = createReportViewModel.Description, DiseaseName = createReportViewModel.DiseaseName, IsChronicDisease = createReportViewModel.IsChronicDisease, PatientId = createReportViewModel.PatientId }; await _reportService.CreateReport(reportCreationResources); _session.SetString("ReportSaved", "true"); return(RedirectToAction("CreateReport")); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult Create() { CreateReportViewModel viewModel = new CreateReportViewModel(); db.Locations.ToList().ForEach(x => viewModel.Locations.Add(new Checkbox <Location>(x))); return(View(viewModel)); }
public async Task <IActionResult> Report(int?id, CreateReportViewModel viewModel, CancellationToken cancellationToken) { if (id is null or default(int)) { return(NotFound()); } GetPromptViewModel?prompt = await _mediator.Send(new GetPromptQuery(id.Value), cancellationToken); if (prompt == null) { return(NotFound()); } if (!ModelState.IsValid) { viewModel.Prompt = prompt; return(View(viewModel)); } viewModel.Command.PromptId = id.Value; await _mediator.Send(viewModel.Command, cancellationToken); return(RedirectToAction("View", new { id, reported = true })); }
public IActionResult Create(string userId) { var model = new CreateReportViewModel { ReportedUserId = userId }; return(View(model)); }
public async Task <IActionResult> Create(CreateReportViewModel model, string userId) { model.ReportedUserId = userId; var report = model.Map <CreateReportViewModel, Report>(); await this.reportsService.SubmitReport(report, this.User.Identity.Name); this.TempData["Success"] = "Thank you for your report, our admins will consider it soon."; return(RedirectToAction(nameof(ProductsController.Index), "Products", new { area = "Shopping" })); }
public ActionResult Details(CreateReportViewModel model) { List <Quote> matchedQuotes = GetMatchingQuotes(model); List <string> matchedColumns = model.ColumnsToInclude.Where(x => x.IsChecked).Select(x => x.Item).ToList(); return(View(new ReportDetailsViewModel() { Columns = matchedColumns, Quotes = matchedQuotes })); }
public async Task <IActionResult> Create() { var author = await _userManager.FindByNameAsync(User.Identity.Name); var model = new CreateReportViewModel { AuthorId = author.Id, Managers = SystemOperations.GetProjectManagerViewModels(author.Id, _managerData), //List of all managers of this user Projects = SystemOperations.GetInProgressProjectViewModels(_projectService), //All in progress projects Activities = _activityData.GetParentActivities().ToList() //List of main activities }; return(View(model)); }
public void Create(CreateReportViewModel viewModel) { FilmHausDbContext.Reports.Add(new Report { ReportId = Guid.NewGuid(), ReviewReportedId = viewModel.ReviewReportedId, ReportedOn = DateTime.Now, ResolvedOn = null, ReportStatus = ReportStatus.Unresolved, ReportReason = viewModel.ReportReason, ReportingUserId = viewModel.ReportingUserId, UserReportedId = viewModel.UserReportedId }); FilmHausDbContext.SaveChanges(); ReviewService.FlagReviewByReviewId(viewModel.ReviewReportedId); }
private List <Quote> GetMatchingQuotes(CreateReportViewModel model) { List <int> selectedLocations = model.Locations.Where(checkbox => checkbox.IsChecked).Select(checkbox => checkbox.Item.Id).ToList(); double maxDiscountPercentage = model.MaxDiscountPercentage ?? double.MaxValue; double minDiscountPercentage = model.MinDiscountPercentage ?? double.MinValue; double maxDiscountDollars = model.MaxDiscountDollars ?? double.MaxValue; double minDiscountDollars = model.MinDiscountDollars ?? double.MinValue; string city = model.City ?? string.Empty; string address = model.Address ?? string.Empty; model.StartDate = model.StartDate ?? DateTime.MinValue; model.EndDate = model.EndDate ?? DateTime.MaxValue; address = address.ToLower(); /* seems EF does something odd when we next this ToLower() * call below (empty string never matches anything when it should match all) */ ExpressionStarter <Quote> isMostlyMatched = PredicateBuilder.New <Quote>(q => (q.Customer.AddressLine1 + q.Customer.AddressLine2).ToLower().Contains(address) && selectedLocations.Contains(q.Location.Id) && model.StartDate <= q.DateCreated && q.DateCreated <= model.EndDate && minDiscountPercentage <= q.DiscountPercentage && q.DiscountPercentage <= maxDiscountPercentage && minDiscountDollars <= q.EligibleCost && q.EligibleCost <= maxDiscountDollars && q.Customer.City.Contains(city)); // These ones only work with exact equality ExpressionStarter <Quote> matchesZip, matchesState, matchesNumberInHousehold; matchesZip = matchesNumberInHousehold = matchesState = PredicateBuilder.New <Quote>(true); if (model.ZipCode != null) { matchesZip.DefaultExpression = q => q.Customer.ZipCode == model.ZipCode; } if (model.State != null) { matchesState.DefaultExpression = q => q.Customer.State == model.State; } if (model.NumberInHousehold != null) { matchesNumberInHousehold.DefaultExpression = q => q.CurrentNumberInHousehold == model.NumberInHousehold; } return(IncludeAllNavigationProperties(db.Quotes) .AsExpandable() .Where(isMostlyMatched.And(matchesZip.And(matchesState).And(matchesNumberInHousehold))).ToList()); }
public ActionResult Create(CreateReportViewModel viewModel) { if (!ModelState.IsValid) { return(RedirectToAction("MyReviews", "Reviews")); } try { ReportService.Create(viewModel); } catch { throw; } return(RedirectToAction("Index", "Home")); }
public IActionResult Create(CreateReportViewModel model) { model.Managers = SystemOperations.GetProjectManagerViewModels(model.AuthorId, _managerData); model.Projects = SystemOperations.GetInProgressProjectViewModels(_projectService); model.Activities = _activityData.GetParentActivities().ToList(); if (ModelState.IsValid) { if (model.TaskStartTime >= model.TaskEndTime) { ModelState.AddModelError("", "زمان ورود و خروج را بررسی کنید."); return(View(model)); } //Save report Attachment var report = new Report { Title = model.Title, Text = model.Text, ProjectId = model.ProjectId, AuthorId = model.AuthorId, ActivityId = model.ActivityId, SubActivityId = model.SubActivityId, ActivityApendix = model.ActivityApendix, TaskStartTime = model.TaskStartTime, TaskEndTime = model.TaskEndTime, Date = DateTime.Now, AttachmentName = model.AttachmentName }; var savedReport = _reportData.Add(report, model.ProjectManagerIds); //Saving Report if (savedReport == null) { ModelState.AddModelError("", "مشکل در ایجاد گزارش."); return(View(model)); } return(RedirectToAction("ManageReports", "Account")); } return(View(model)); }
public IActionResult Edit(CreateReportViewModel model) { model.Managers = SystemOperations.GetProjectManagerViewModels(model.AuthorId, _managerData); model.Projects = SystemOperations.GetInProgressProjectViewModels(_projectService); model.Activities = _activityData.GetParentActivities().ToList(); if (ModelState.IsValid) { if (model.TaskStartTime >= model.TaskEndTime) { ModelState.AddModelError("", "زمان شروع و پایان را بررسی کنید."); return(View(model)); } //Save report Attachment var report = _reportData.Get(model.Id); report.Title = model.Title; report.Text = model.Text; report.ProjectId = model.ProjectId; report.ActivityId = model.ActivityId; report.SubActivityId = model.SubActivityId == 0 ? null : model.SubActivityId; report.ActivityApendix = model.ActivityApendix; report.TaskStartTime = model.TaskStartTime; report.TaskEndTime = model.TaskEndTime; if (model.AttachmentName != null) //preventing from saving null instead of last attachment { report.AttachmentName = model.AttachmentName; } var result = _reportData.Update(report, model.ProjectManagerIds); if (!result) { ModelState.AddModelError("", "مشکل در بروزرسانی!"); return(View(model)); } return(RedirectToAction("ManageReports", "Account")); } return(View(model)); }
public IActionResult Edit(short id) { var report = _reportData.Get(id); if (report == null) { return(NotFound()); } if (report.Author.UserName != User.Identity.Name) { return(RedirectToAction("AccessDenied", "Home")); } var model = new CreateReportViewModel { Id = report.Id, AuthorId = report.AuthorId, ActivityId = report.Activity.Id, SubActivityId = report.SubActivityId ?? null, ActivityApendix = report.ActivityApendix, TaskStartTime = report.TaskStartTime, TaskEndTime = report.TaskEndTime, ProjectId = report.ProjectId, Managers = SystemOperations.GetProjectManagerViewModels(report.AuthorId, _managerData), Projects = SystemOperations.GetInProgressProjectViewModels(_projectService), Activities = _activityData.GetParentActivities().ToList(), //List of main activities ProjectManagerIds = report.ProjectManagers.Select(pm => pm.ManagerId).ToList(), Title = report.Title, Text = report.Text, //If any of project managers submited report with this report IsSubmitedByManager = report.ManagerReports != null && report.ManagerReports.Any() ? true : false, AttachmentName = report.AttachmentName != null ? report.AttachmentName : null }; return(View(model)); }
public ActionResult Create(CreateReportViewModel mcReports) { try { var sFile = Request.Form["SelectedReportFile.SelectedFile"]; var sFolder = Request.Form["SelectedOutputFolder.SelectedFolder"]; if (sFile == null) { sFile = ""; } if (sFolder == null) { sFolder = ""; } mcReports.SelectedOutputFolder.SelectedFolder = sFolder; mcReports.SelectedReportFile.SelectedFile = sFile; if (String.IsNullOrWhiteSpace(mcReports.name)) { ModelState.AddModelError("name", "The report must have a name."); } if (sFile.Length < 1) { ModelState.AddModelError("SelectedReportFile.SelectedFile", "No report file was selected"); } if (sFolder.Length < 1) { ModelState.AddModelError("SelectedOutputFolder.SelectedFolder", "No report output location was selected or location was not valid."); } try { if (!(new FileInfo(sFile).Exists)) { ModelState.AddModelError("SelectedReportFile.SelectedFile", "No report file was selected or report file is not valid."); } } catch (Exception) { ModelState.AddModelError("SelectedReportFile.SelectedFile", "No report file was selected or report file is not valid."); } try { if (!(new DirectoryInfo(sFolder).Exists)) { ModelState.AddModelError("SelectedOutputFolder_SelectedFolder", "No report output location was selected or location was not valid. Exception"); } } catch (Exception) { ModelState.AddModelError("SelectedOutputFolder_SelectedFolder", "No report output location was selected or location was not valid. Exception"); } if (ModelState.IsValid) { //load the crystal report CrRptDef crRpt = new CrRptDef(sFile); //save report to database and retrieve key mc_reports mc = new mc_reports { name = mcReports.name, description = mcReports.description, cr_filepath = sFile, output_path = sFolder, date_created = DateTime.Now, date_changed = DateTime.Now, user_created = User.Identity.Name, user_changed = User.Identity.Name }; db.mc_reports.Add(mc); db.SaveChanges(); Console.WriteLine(mc.id); var id = mc.id; //insert the child entities foreach (var p in crRpt.parameters) { var mrp = new mc_report_params { report_id = mc.id, name = p.name, type = p.type, default_value = p.default_value }; db.mc_report_params.Add(mrp); } db.SaveChanges(); foreach (var f in crRpt.forumulafields) { mc_report_formulas mrf = new mc_report_formulas(); mrf.report_id = mc.id; mrf.name = f.name; mrf.formula_name = f.formula_name; mrf.code = f.code; mrf.use_formula = f.use_formula; db.mc_report_formulas.Add(mrf); } db.SaveChanges(); return(RedirectToAction("Edit", new { id = id })); } else { return(View(mcReports)); } } catch (Exception ex) { ModelState.AddModelError("name", "A fatal exception has occured your report was not loaded. Please contact the Application Development team for assistance."); return(View(mcReports)); } }