// GET: Reports/Create
        public ActionResult Create()
        {
			var vm = new ReportViewModel();
			vm = RefreshViewModel(vm);

			return View(vm);
        }
        public ActionResult PhenotypeEntry(PhenotypeReportViewModel mapView)
        {
            if (!ModelState.IsValid)
            {
                return(View(mapView));
            }

            ReportViewModel reportVM = r_repo.GetReportForPhenotype(mapView);

            TempData["ReportViewModel"] = reportVM;

            return(RedirectToAction("ReportView"));
        }
        public IActionResult SubmitReport(string postId)
        {
            ReportViewModel viewModel = this.reportsService.GetSubmitReportViewModel(postId, User);

            if (viewModel == null)
            {
                var result = this.View("Error", this.ModelState);
                ViewData["Message"] = ErrorConstants.PageNotAvaivableMessage;
                result.StatusCode   = (int)HttpStatusCode.BadRequest;
                return(result);
            }
            return(View(viewModel));
        }
        public ActionResult MapComponents(MapComponentReportViewModel mapView)
        {
            if (!ModelState.IsValid)
            {
                return(View(mapView));
            }

            ReportViewModel reportVM = r_repo.GetReportForMapComponent(mapView);

            TempData["ReportViewModel"] = reportVM;

            return(RedirectToAction("ReportView"));
        }
        public ActionResult MapInventory(MapInventoryReportViewModel mapInventory)
        {
            if (!ModelState.IsValid)
            {
                return(View(mapInventory));
            }

            ReportViewModel reportVM = r_repo.GetReportForMapInventory(mapInventory);

            TempData["ReportViewModel"] = reportVM;

            return(RedirectToAction("ReportView"));
        }
        public ActionResult Distributions(DistributionReportViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                return(View(vm));
            }

            ReportViewModel reportVM = r_repo.GetReportForDistributions(vm);

            TempData["ReportViewModel"] = reportVM;

            return(RedirectToAction("ReportView"));
        }
Esempio n. 7
0
        public void ReportViewModel_NumberOfUsers_Set_Default_Should_Pass()
        {
            // Arrange
            var myTest         = new ReportViewModel();
            int myTestNumUsers = 3;

            // Act
            myTest.NumberOfUsers = myTestNumUsers;
            var result = myTest.NumberOfUsers;

            // Assert
            Assert.AreEqual(3, result);
        }
        /// <summary>
        /// Creates a new instance of the <see cref="CompletenessReportUserControl"/> class.
        /// </summary>
        public CompletenessReportUserControl()
        {
            InitializeComponent();

            ReportUserControl userControl = new ReportUserControl();
            ReportViewModel   viewModel   = userControl.ViewModel;

            viewModel.ReportType                   = "Completeness";
            viewModel.ReportGenerationTime         = new DateTime(1, 1, 1, 2, 0, 0);
            viewModel.OriginalReportGenerationTime = viewModel.ReportGenerationTime;

            AddChild(userControl);
        }
Esempio n. 9
0
 public static Report ToServiceModel(this ReportViewModel viewModel)
 {
     return(viewModel != null ? new Report
     {
         Id = viewModel.Id,
         Title = viewModel.Title,
         Summary = viewModel.Summary,
         Author = viewModel.Author,
         PublicationDate = viewModel.PublicationDate,
         File = viewModel.File,
         DownloadCount = viewModel.DownloadCount,
     } : null);
 }
Esempio n. 10
0
        /// <summary>
        /// Shows a report on received, withdrawn, sold and moved products
        /// </summary>
        /// <param name="reportFilter">Filtering data</param>
        /// <returns></returns>
        public IActionResult Index(IDictionary <string, string> data)
        {
            var a = Request.QueryString.ToString().Split('&').Where(s => s.Contains("WarehouseId")).Select(s => s.Substring(s.IndexOf('=') + 1)).ToList();

            data.Remove("WarehouseId");
            for (int i = 0; i < a.Count(); i++)
            {
                data.Add($"Warehouse{i}", a[i]);
            }
            if (!FilterValid())
            {
                return(BadRequest());
            }
            ReportViewModel reportFilter = new ReportViewModel(data);
            var             user         = _context.Users.Find(User.FindFirst(ClaimTypes.NameIdentifier).Value);

            //var wareHouseId = user.WarehouseId;
            ViewBag.Names      = new SelectList(_context.Products, "Id", "Name");
            ViewBag.Types      = new SelectList(_context.Types, "Id", "Name");
            ViewBag.Users      = new SelectList(_context.Users.Where(u => u.Id != user.Id), "Id", "UserName");
            ViewBag.Warehouses = new SelectList(_context.Warehouses, "Id", "Number");
            if (reportFilter.Deal == null)
            {
                if (reportFilter.DateFrom == DateTime.MinValue)
                {
                    reportFilter.DateFrom = DateTime.MinValue.Date;
                }
                return(View(reportFilter));
            }
            if (reportFilter.Deal.Equals("0"))
            {
                Import(reportFilter);
            }
            else if (reportFilter.Deal.Equals("1"))
            {
                Saled(reportFilter);
            }
            else if (reportFilter.Deal.Equals("2"))
            {
                Export(reportFilter);
            }
            else if (reportFilter.Deal.Equals("3"))
            {
                Moved(reportFilter);
            }
            else
            {
                return(BadRequest());
            }
            return(View(reportFilter));
        }
        public ActionResult UpdateDelete(MenuItemMasterViewModel MIMViewModel, string command)
        {
            UserSession user       = (UserSession)Session["User"];
            string      PageAction = "";
            bool        result     = false;

            if (Request.Files.Count > 0)
            {
                HttpPostedFileBase file = Request.Files["FileUploaded"];
                if ((file != null) && (file.ContentLength > 0) && !string.IsNullOrEmpty(file.FileName))
                {
                    //string fileName = file.FileName;
                    // store the file inside ~/App_Data/uploads folder
                    //string path = "~/App_Data/uploads/" + fileName;
                    //file.SaveAs(Server.MapPath(path));
                    ReportViewModel report = MenuItemMasterManager.ImportExcelUpdate(file.InputStream, user.Username);
                    PageAction = "Import";
                    result     = report.Result;
                    if (!result)
                    {
                        if (report.ErrorLevel == 2)
                        {
                            PageAction = report.Message + ": Import partially";
                        }
                        else
                        {
                            PageAction = report.Message + ": Import";
                        }
                    }
                    else
                    {
                        PageAction = report.Message + ": Import";
                    }
                }
            }
            if (command == "Save")
            {
                result     = MenuItemMasterManager.UpdatePriceTier(MIMViewModel, user.Username);
                PageAction = "Update price";
            }
            if (result)
            {
                TempData["SuccessMessage"] = PageAction + " successful";
                new AuditLogManager().Audit(user.Username, DateTime.Now, "Menu Item Price Update", PageAction, MIMViewModel.MIMMIC, MIMViewModel.MIMNAM);
            }
            else
            {
                TempData["ErrorMessage"] = PageAction + " failed";
            }
            return(RedirectToAction("Index"));
        }
Esempio n. 12
0
        public async Task <IActionResult> Edit(int id, ReportViewModel reportVM)
        {
            if (id != reportVM.ReportID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var report = await _context.Report
                                 .Include(r => r.Category)
                                 .Include(r => r.Shift)
                                 .Include(r => r.Type)
                                 .Include(r => r.User)
                                 .Include(r => r.onCallEscalate)
                                 .FirstOrDefaultAsync(m => m.ReportID == id);

                    if (User.IsInRole(Constants.ADMIN))
                    {
                        report.Category = _context.Category.SingleOrDefault(e => e.CategoryId.ToString() == reportVM.CategoryID);
                    }
                    report.TicketNo       = reportVM.TicketNo;
                    report.Description    = reportVM.Description;
                    report.ArrivalTime    = reportVM.ArrivalTime != null ? reportVM.ArrivalTime : null;
                    report.TimeSpent      = reportVM.TimeSpent;
                    report.StartTime      = reportVM.StartTime;
                    report.EndTime        = reportVM.EndTime != null ? reportVM.EndTime : null;
                    report.Shift          = _context.Shift.Find(Convert.ToInt32(reportVM.ShiftID));
                    report.Type           = _context.Type.Find(Convert.ToInt32(reportVM.TypeID));
                    report.onCallEscalate = _context.onCallEscalates.Find(Convert.ToInt32(reportVM.OnCallEscalateID));
                    _context.Update(report);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ReportExists(reportVM.ReportID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            return(View(reportVM));
        }
Esempio n. 13
0
        public ActionResult DriverWiseBataReport(ReportViewModel model)
        {
            try
            {
                DateTime startDate;
                DateTime EndDate;
                DateTime.TryParse(model.ReportDto.StartDate.ToLongDateString(), out startDate);
                DateTime.TryParse(model.ReportDto.EndDate.ToLongDateString(), out EndDate);
                model.ReportDto.StartDate = startDate.AddHours(6);
                model.ReportDto.EndDate   = EndDate.AddHours(6);

                IEnumerable <TripDto>         trips = _tripService.RetrieveDriverWiseBataDetails(model.ReportDto).Where(a => a.IsReopened != true).ToList();
                IEnumerable <BataReportModel> bata  = trips.Where(a => a.CustomBata != null || a.TripBata != null).GroupBy(a => a.UpdatedDate.Date).Select(a => new BataReportModel
                {
                    Date        = a.Key,
                    BataDetails = a.Select(x => new DailyDriverPerformanceDto
                    {
                        VoucherNumber    = x.VoucherNumber,
                        DispatchedHotel  = x.DispatchedHotel,
                        Createdby        = x.Createdby,
                        Updatedby        = x.Updatedby,
                        DriverName       = x.DriverName,
                        VehicleNumber    = x.VehicleNumber,
                        Packages         = x.Packages,
                        CreatedDate      = x.CreatedDate,
                        UpdatedDate      = x.UpdatedDate,
                        EmployeeNumber   = x.EmployeeNumber,
                        BataAmount       = x.TripBata == null ? 0 : x.TripBata.FirstOrDefault().Amount,
                        BataDescription  = x.TripBata == null ? "" : x.TripBata.FirstOrDefault().Description,
                        CustomBataAmount = x.CustomBata == null ? 0 : x.CustomBata.FirstOrDefault().CustomAmount,
                    }).ToList()
                }).ToList();
                ReportViewModel models = new ReportViewModel()
                {
                    DriverReportList = Mapper.Map <List <DailyDriverPerformanceDto> >(trips).ToList(),
                    BataList         = bata,
                    CurrentDate      = CustomDataHelper.CurrentDateTimeSL.GetCurrentDate(),
                    Driver           = GetDriverNames(),
                    Vehicle          = GetVehicleNumbers(),
                    Employee         = GetEmployeeNumbers(),
                    ReportDto        = model.ReportDto,
                };
                ViewBag.Content = true;
                TempData["DriverReportTemp"] = models;
                return(View(models));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 14
0
        public void ReportViewModel_NumberOfUsers_Set_Default_Should_Pass()
        {
            //Arrange
            var myTest = new ReportViewModel();

            //Act
            var myTestNumberOfUsers = myTest.NumberOfUsers;

            myTest.NumberOfUsers = 7;

            //Assert
            Assert.AreNotEqual(myTestNumberOfUsers, myTest.NumberOfUsers);
            Assert.AreEqual(myTest.NumberOfUsers, 7);
        }
Esempio n. 15
0
        public IActionResult Report(ReportViewModel model)
        {
            if (!baseRepository.ValidationToken())
            {
                return(Redirect("/Login/Index"));
            }

            SetViewBag();

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            model.Result = new ReportResult();

            model.Result = baseRepository.ExecuteCommand(conn =>
                                                         conn.Query <ReportResult>("SELECT" +
                                                                                   " (SELECT COUNT([HV].Approved) FROM [TavanirStage].[Basic].[TimeSeries] AS [TS]" +
                                                                                   " INNER JOIN [TavanirStage].[Stage].[HistoricalValues] AS [HV] ON [TS].[Id] = [HV].[TimeSeriesId] AND [HV].[Approved] = '1'" +
                                                                                   " WHERE [TS].[Token] = [AT].[Token]) AS [ApprovedCounts]," +
                                                                                   " (SELECT COUNT([HV].Approved) FROM [TavanirStage].[Basic].[TimeSeries] AS [TS]" +
                                                                                   " INNER JOIN [TavanirStage].[Stage].[HistoricalValues] AS [HV] ON [TS].[Id] = [HV].[TimeSeriesId] AND [HV].[Approved] = '0'" +
                                                                                   " WHERE [TS].[Token] = [AT].[Token]) AS [NotApproveCounts]" +
                                                                                   " FROM [TavanirStage].[Stage].[AuthorizationTokens] AS [AT]" +
                                                                                   " WHERE [AT].[Code] = @Code",
                                                                                   new { @Code = model.Code }).FirstOrDefault());

            if (model.Result.ApprovedCounts > 0 || model.Result.NotApproveCounts > 0)
            {
                model.Result.CodeFounded = true;

                model.Result.ListNotAproved = baseRepository.ExecuteCommand(conn =>
                                                                            conn.Query <ReportNotAproved>("SELECT [HV].[RowIndex], [HV].[RecivedValue], [HV].[Mesaage]" +
                                                                                                          " FROM [TavanirStage].[Stage].[AuthorizationTokens] AS [AT] " +
                                                                                                          " INNER JOIN [TavanirStage].[Basic].[TimeSeries] AS [TS] ON [AT].[Token] = [TS].[Token]" +
                                                                                                          " INNER JOIN [TavanirStage].[Stage].[HistoricalValues] AS [HV] ON [TS].[Id] = [HV].[TimeSeriesId] AND [HV].[Approved] = '0'" +
                                                                                                          " INNER JOIN [TavanirStage].[Stage].[DataMembers] AS [DM] ON [HV].[DataMemberId] = [DM].[Id]" +
                                                                                                          " INNER JOIN [TavanirStage].[Basic].[DataItems] AS [DI] ON [DM].[DataItemId] = [DI].[Id]" +
                                                                                                          " WHERE [AT].[Code] = @Code",
                                                                                                          new { @Code = model.Code }).ToList());
            }
            else
            {
                model.Result.CodeFounded = false;
                ModelState.AddModelError(nameof(model.Code), "کد پیگیری وارد شده معتبر نمی‌باشد.");
            }

            return(View(model));
        }
Esempio n. 16
0
        // GET: Reports/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ReportViewModel report = Mapper.Map <ReportViewModel>(reportService.Get(id.Value));

            if (report == null)
            {
                return(HttpNotFound());
            }
            return(View(report));
        }
        public JsonResult getyear(int compid, int compliancetypeid)
        {
            int             sd    = 0;
            int             ed    = 0;
            List <string>   years = new List <string>();
            ReportViewModel model = new ReportViewModel();

            OrgService.OrganizationServiceClient organizationservice = new OrgService.OrganizationServiceClient();
            string  strxmlcompliancetype = organizationservice.GetParticularCompliance(compliancetypeid);
            DataSet dsComplianceType     = new DataSet();

            dsComplianceType.ReadXml(new StringReader(strxmlcompliancetype));
            if (dsComplianceType.Tables.Count > 0)
            {
                string   ComplianceName = Convert.ToString(dsComplianceType.Tables[0].Rows[0]["Compliance_Type_Name"]);
                DateTime StartDate      = Convert.ToDateTime(dsComplianceType.Tables[0].Rows[0]["Start_Date"]);
                DateTime EndDate        = Convert.ToDateTime(dsComplianceType.Tables[0].Rows[0]["End_date"]);

                sd = StartDate.Year;
                ed = EndDate.Year;
            }

            string  strxmlyear = organizationservice.getDefaultCompanyDetails(compid);
            DataSet dsyear     = new DataSet();

            dsyear.ReadXml(new StringReader(strxmlyear));
            if (dsyear.Tables.Count > 0)
            {
                model.StartDate = Convert.ToDateTime(dsyear.Tables[0].Rows[0]["Calender_StartDate"]);
                model.yearid    = model.StartDate.Year;
                if (sd == ed)
                {
                    model.years = Enumerable.Range(model.yearid, DateTime.Now.Year - (model.yearid - 1)).OrderByDescending(i => i);
                    //model.yearid = DateTime.Now.Year;
                }
                else
                {
                    int count = DateTime.Now.Year - (model.yearid - 1);
                    for (int i = 1; i <= count; i++)
                    {
                        years.Add(model.yearid.ToString() + "-" + (model.yearid + 1));
                        ++model.yearid;
                    }
                    years.Reverse();

                    return(Json(years, JsonRequestBehavior.AllowGet));
                }
            }
            return(Json(model.years, JsonRequestBehavior.AllowGet));
        }
Esempio n. 18
0
 protected void ReportEditButtonClick(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         ReportBLL       bll    = new ReportBLL(connectionString);
         ReportViewModel report = new ReportViewModel();
         report.ReportID          = Convert.ToInt32(Request.QueryString["ReportID"]);
         report.ReportName        = ReportName.Text;
         report.ReportDescription = ReportDescription.Text;
         report.DateOfIncident    = Convert.ToDateTime(DateOfIncident.Text);
         bll.EditReport(report);
         Response.Redirect("~/Reports.aspx");
     }
 }
Esempio n. 19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ReportBLL       bll    = new ReportBLL(connectionString);
                ReportViewModel report = bll.GetReportById(Convert.ToInt32(Request.QueryString["ReportID"]));

                ReportID.Text          = report.ReportID.ToString();
                DateOfIncident.Text    = report.DateOfIncident.ToString();
                CarID.Text             = report.CarID.ToString();
                ReportName.Text        = report.ReportName;
                ReportDescription.Text = report.ReportDescription;
            }
        }
        public void ReportViewModel_NumberOfUsers_Set_Default_Should_Pass()
        {
            // Arrange
            var myTest = new ReportViewModel
            {
                NumberOfUsers = 1
            };

            // Act
            myTest.NumberOfUsers = 2;

            // Assert
            Assert.AreEqual(2, myTest.NumberOfUsers);
        }
Esempio n. 21
0
        public ActionResult CreatePost(ReportViewModel model)
        {
            if (!this.services.Authorizer.Authorize(Permissions.ManageQueries, T("Not authorized to list Reports")))
            {
                return(new HttpUnauthorizedResult());
            }

            if (!this.ModelState.IsValid)
            {
                model = model ?? new ReportViewModel();
                this.FillRelatedData(model);
                return(this.View("Create", model));
            }

            var groupByDescriptor = this.DecodeGroupByCategoryAndType(model.CategoryAndType);

            if (groupByDescriptor == null)
            {
                this.ModelState.AddModelError("CategoryAndType", T("There is no GroupBy field matched with the given parameters").Text);
                this.FillRelatedData(model);
                return(this.View("Create", model));
            }

            AggregateMethods selectedAggregate = (AggregateMethods)model.AggregateMethod;

            if (!groupByDescriptor.AggregateMethods.Any(c => c == selectedAggregate))
            {
                this.ModelState.AddModelError("AggregateMethod", T("The selected field does't support the selected Aggregate method").Text);
                this.FillRelatedData(model);
                return(this.View("Create", model));
            }

            ReportRecord newReport = new ReportRecord
            {
                Title = model.Title,
                Name  = model.Name,
                Query = new QueryPartRecord {
                    Id = model.QueryId.Value
                },
                GroupByCategory = groupByDescriptor.Category,
                GroupByType     = groupByDescriptor.Type,
                AggregateMethod = model.AggregateMethod,
                GUID            = Guid.NewGuid().ToString()
            };

            this.reportRepository.Create(newReport);
            this.reportRepository.Flush();

            return(this.RedirectToAction("Index"));
        }
Esempio n. 22
0
        public async Task <IActionResult> Report(ReportViewModel inputModel)
        {
            if (!ModelState.IsValid)
            {
                var result = this.View("Error", this.ModelState);
                result.StatusCode = (int)HttpStatusCode.BadRequest;
                return(result);
            }

            var currentUserId = this.userServices.GetUserId(User);
            await reportsService.AddReport(currentUserId, inputModel.PostId, inputModel.ReportReason);

            return(RedirectToAction("Index", "NewsFeed"));
        }
Esempio n. 23
0
        public async Task <IActionResult> Report(string username)
        {
            string accessToken = await HttpContext.GetTokenAsync("access_token");

            HttpClient client = new HttpClient();

            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);

            ReportViewModel report = new ReportViewModel();

            report.Username = username;

            return(View(report));
        }
Esempio n. 24
0
        public async Task <IActionResult> CreateReport([Bind("Title, LocationOfReport, DateTimeOfReport, TypeOfHazard, Description, Status, ImageToUpload")] ReportViewModel newReport)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    string fileName = "";

                    if (newReport.ImageToUpload != null)
                    {
                        // Store image locally
                        var extension = "." + newReport.ImageToUpload.FileName.Split('.')[newReport.ImageToUpload.FileName.Split('.').Length - 1];
                        fileName = Guid.NewGuid().ToString() + extension;
                        var path = Directory.GetCurrentDirectory() + "\\wwwroot\\images\\reports\\" + fileName;
                        using (var bits = new FileStream(path, FileMode.Create))
                        {
                            newReport.ImageToUpload.CopyTo(bits);
                        }
                    }

                    // Create Object
                    Report report = new Report()
                    {
                        Title            = newReport.Title,
                        CreatedOn        = DateTime.UtcNow,
                        ModifiedOn       = DateTime.UtcNow,
                        LocationOfReport = newReport.LocationOfReport,
                        DateTimeOfReport = newReport.DateTimeOfReport,
                        TypeOfHazard     = newReport.TypeOfHazard,
                        Description      = newReport.Description,
                        Status           = newReport.Status,
                        Image            = "/images/reports/" + fileName,
                        Reporter         = await _userManager.GetUserAsync(User)
                    };

                    _logger.LogInformation("User: "******", created a report");
                    _reportRepository.AddReport(report);
                    return(RedirectToAction("ViewReports"));
                }
                else
                {
                    return(View(newReport));
                }
            }
            catch (Exception e)
            {
                _logger.LogError(e.Message);
                return(View("Error"));
            }
        }
Esempio n. 25
0
        public IActionResult Create(int postId, string slug)
        {
            ReportViewModel viewModel = new ReportViewModel();
            JobPost         jobPost   = this.jobPostsService.GetJobPost(postId);

            if (jobPost == null)
            {
                return(this.NotFound());
            }

            viewModel.PostId    = jobPost.Id;
            viewModel.PostTitle = jobPost.Title;
            return(this.View(viewModel));
        }
Esempio n. 26
0
 public ActionResult SetReport(int?id)
 {
     try
     {
         //string WorkerE = Request.QueryString["email"];
         var r = new ReportViewModel();
         //r.Worker = WorkerE;
         return(View(r));
     }
     catch (ValidationException ex)
     {
         return(Content(ex.Message));
     }
 }
Esempio n. 27
0
        public ActionResult DeleteReport(int?id)
        {
            try
            {
                ReportDTO Report = ReportService.GetReport(id);
                var       r      = new ReportViewModel();

                return(View(r));
            }
            catch (ValidationException ex)
            {
                return(Content(ex.Message));
            }
        }
Esempio n. 28
0
        // GET: Reports

        public ActionResult Index(int id, int rptID = 0)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(Redirect("~/"));
            }

            ReportViewModel model = new ReportViewModel(id, rptID);

            model.AgreementNumber = Security.GetMemberID();
            model.ContactName     = Security.GetFullName();

            return(View(model));
        }
Esempio n. 29
0
        public void RepoertViewModel_Set_NumberOfUsers_Default_Should_Pass()
        {
            //Arrage
            var myTest          = new ReportViewModel();
            var myNumberOfUsers = 5;

            //Act
            myTest.NumberOfUsers = myNumberOfUsers;
            var result = myTest.NumberOfUsers;

            //Assert

            Assert.AreEqual(5, result);
        }
Esempio n. 30
0
 public ReportView(ReportViewModel viewModel, string helpFileName)
 {
     // Inicializa los componentes
     InitializeComponent();
     // Inicializa la vista de datos
     grdData.DataContext = ViewModel = viewModel;
     FormView            = new BaseFormView(ViewModel);
     // Inicializa el editor
     udtEditor.ChangeHighLightByExtension("xml");
     udtEditor.Text = ViewModel.Content;
     // Inicializa el árbol de ayudas
     udtHelpTree.HelpFileName = helpFileName;
     udtHelpTree.OpenHelp    += (sender, evntArgs) => OpenHelp(evntArgs.HelpItem);
 }
Esempio n. 31
0
        public ActionResult View_Report(int rid, string name)
        {
            if (Session["userId"] == null)
            {
                return(RedirectToAction("Index", "UserHome"));
            }
            _ReportService.SetSeen(rid);
            ReportViewModel m = new ReportViewModel();

            m.ReportCount = _ReportService.GetByUnseenStatus().Count();
            m.report      = _ReportService.GetById(rid);
            m.name        = _MemberService.GetById(m.report.MemeberId).Name;
            return(View(m));
        }
		public ActionResult Create(ReportViewModel reportViewModel)
        {
            if (ModelState.IsValid)
            {
                reportViewModel.Report.CleanName();

				using(var db = new RptContext())
				{
					db.Reports.Add(reportViewModel.Report);
					db.SaveChanges();
				}
                return RedirectToAction("Index");
            }

			reportViewModel = RefreshViewModel(reportViewModel);
			return View(reportViewModel);
        }
        // GET: Reports/Edit/5
		public ActionResult Edit(int? id)
        {
            if (id == null)
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);

            var report = _db.Reports.Find(id);
            if (report == null)
                return HttpNotFound();

			var reportViewModel = new ReportViewModel();
            reportViewModel.Report = report;
			reportViewModel = RefreshViewModel(reportViewModel);

			return View(reportViewModel);
        }
		public ActionResult Edit(ReportViewModel reportViewModel)
        {
            if (ModelState.IsValid)
            {
                reportViewModel.Report.CleanName();

				using(var db = new RptContext())
				{
					db.Entry(reportViewModel.Report).State = EntityState.Modified;
					db.SaveChanges();
				}
                return RedirectToAction("Index");
            }

			reportViewModel = RefreshViewModel(reportViewModel);
			return View(reportViewModel);
        }
Esempio n. 35
0
        // GET:Exportar
        public ActionResult Index()
        {
            var ReportViewModel = new ReportViewModel();
            ReportViewModel.Countries = db.Countries.Where(c=>c.Active == true)
                    .Select(c => new CountryView()
                    {
                        Id = c.ID.ToString(),
                        Name = c.Name
                    }).ToArray();
            IQueryable<Institution> institutions = null;
            var user = UserManager.FindById(User.Identity.GetUserId());
            ReportViewModel.CountryID = user.Institution.CountryID ?? 0;
            if (user.Institution.AccessLevel == AccessLevel.All)
            {
                ReportViewModel.DisplayCountries = true;
                ReportViewModel.DisplayHospitals = true;
            }
            else if (user.Institution is Hospital || user.Institution is AdminInstitution)
            {
                ReportViewModel.DisplayHospitals = true;

                if (user.Institution.AccessLevel == AccessLevel.Country)
                {
                    institutions = db.Institutions.OfType<Hospital>()
                                  .Where(i => i.CountryID == user.Institution.CountryID);
                }
                else if (user.Institution.AccessLevel == AccessLevel.Area)
                {
                    institutions = db.Institutions.OfType<Hospital>()
                                   .Where(i => i.AreaID == user.Institution.AreaID);
                }
                else
                {
                    institutions = db.Institutions.OfType<Hospital>()
                                   .Where(i => i.ID == user.Institution.ID);
                }
            }
            else
            {
                ReportViewModel.DisplayLabs = true;

                if (user.Institution.AccessLevel == AccessLevel.Country)
                {
                    institutions = db.Institutions.OfType<Lab>()
                                   .Where(i => i.CountryID == user.Institution.CountryID);
                }
                else if (user.Institution.AccessLevel == AccessLevel.Area)
                {
                    institutions = db.Institutions.OfType<Lab>()
                                   .Where(i => i.AreaID == user.Institution.AreaID);
                }
                else
                {
                    institutions = db.Institutions.OfType<Lab>()
                                   .Where(i => i.ID == user.Institution.ID);
                }
            }

            if (institutions != null)
            {
                ReportViewModel.hospitals = institutions.OfType<Hospital>().Select(i => new LookupView<Hospital>()
                {
                    Id = i.ID.ToString(),
                    Name = i.Name
                }).ToArray();

                ReportViewModel.labs = (from institution in db.Institutions.OfType<Lab>()
                                  select new LookupView<Lab>()
                                  {
                                      Id = institution.ID.ToString(),
                                      Name = institution.Name
                                  }).ToArray();
            };
            return View(ReportViewModel);
        }
		private ReportViewModel RefreshViewModel(ReportViewModel reportViewModel)
		{
			reportViewModel.Connections = _db.Connections.OrderBy(ob => ob.Name).ToList();
			reportViewModel.SqlTypes = _db.SqlTypes.OrderBy(ob => ob.Name).ToList();

			return reportViewModel;
		}