Esempio n. 1
0
        public ActionResult Download(int[] reportID)
        {
            csvdata = "Title;Added;Modified;State;Assigned to;Number of activities\n";
            List<IssueViewModel> issueViewModels = new List<IssueViewModel>();
            int al = reportID.Length;
            for (int i = 0; i < al; i++)
            {
                var view = new IssueViewModel
                {
                    cissue = db.Issues.Find(reportID[i]),
                    cactivities = db.Activities.SqlQuery("SELECT * FROM Activity WHERE IssueID='" + reportID[i] + "'")
                };
                issueViewModels.Add(view);

            }
            foreach (IssueViewModel item in issueViewModels)
            {
                csvdata = csvdata + item.cissue.Title + ";" + item.cissue.Added + ";" + item.cissue.Modiefied + ";" + item.cissue.State + ";" + item.cissue.Employee + ";" + item.cactivities.Count() + "\n";
            }
            var data = Encoding.UTF8.GetBytes(csvdata);
            string filename = "reports"+DateTime.Today.ToString("dd-MM-yy")+".csv";
            return File(data, "text/csv", filename);
        }
Esempio n. 2
0
        public ActionResult GetReport(int[] reportID)
        {
            List<IssueViewModel> issueViewModels = new List<IssueViewModel>();
            int al = reportID.Length;
            for(int i = 0; i<al; i++){
                var view = new IssueViewModel {
                    cissue = db.Issues.Find(reportID[i]),
                    cactivities = db.Activities.SqlQuery("SELECT * FROM Activity WHERE IssueID='"+reportID[i]+"'")
                };
                issueViewModels.Add(view);
            }

            var viewModel = new ReportIssueViewModel
            {
                report_issues = issueViewModels
            };

            return View(viewModel);
        }
Esempio n. 3
0
        public ActionResult Details(int id)
        {
            Issue issue = db.Issues.Find(id);
            //check that customer cannot read other issues
            if (System.Web.HttpContext.Current.User.IsInRole("Customer"))
            {
                if (issue.Writer != System.Web.HttpContext.Current.User.Identity.Name)
                {
                    return RedirectToAction("Index", "Issue");
                }
            }
            string current_state;
            switch (issue.State)
            {
                case 0:
                    current_state = "Not started";
                    break;
                case 1:
                    current_state = "Started";
                    break;
                case 2:
                    current_state = "Waiting";
                    break;
                case 3:
                    current_state = "Resolved";
                    break;
                case 4:
                    current_state = "Closed";
                    break;
                default:
                    current_state = "Error";
                    break;
            }
            var viewModel = new IssueViewModel
            {
                cissue = issue,
                cstate = current_state,
                cactivities = db.Activities.SqlQuery("SELECT * FROM Activity WHERE IssueID='"+id+"'")

            };

            return View(viewModel);
        }