public ActionResult Index(IndexIssueRequestModel Model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var issues = db.issues.Include("student");
                    var program = db.programs;
                    var employee = db.employees;
                    List<String> employees = new List<String>();
                    employees.Add("Any");
                    foreach (employee emp in employee)
                    {
                        employees.Add(emp.employeeid.Trim() + " - " + emp.fname.Trim() + " " + emp.lname.Trim());
                    }
                    List<catagory> catagories = new List<catagory>();
                    catagory cat = new catagory() { catagory1 = "Any" };
                    catagories.Add(cat);
                    catagories.AddRange(db.catagories);
                    List<String> collection = new List<String>();
                    collection.Add("Any");
                    foreach (program prog in program)
                    {
                        collection.Add(prog.programcode.ToString().Trim() + " - " + prog.programname.ToString().Trim());
                    }
                    IEnumerable<issue> _issues = issues;
                    if (Model._name != null)
                        _issues = _issues.Where(i => i.issuename.Trim().ToUpper().Contains(Model._name.Trim().ToUpper()));
                    if (Model._employeeid != "Any")
                    {
                        StringBuilder sb = new StringBuilder(Model._employeeid.Trim().ToUpper());
                        sb.Remove(9, sb.Length - 9);
                        _issues = _issues.Where(i => i.employeeid.Trim().ToUpper().Contains(sb.ToString()));
                    }
                    if (Model._status != "Any")
                        _issues = _issues.Where(i => i.status.Trim().ToUpper().Contains(Model._status.Trim().ToUpper()));
                    if (Model._urgency != "Any")
                        _issues = _issues.Where(i => i.urgency.Trim().ToUpper().Contains(Model._urgency.Trim().ToUpper()));
                    if (Model._category != "Any")
                        _issues = _issues.Where(i => i.catagory.Trim().ToUpper().Contains(Model._category.Trim().ToUpper()));
                    if (Model._selectedpcode != "Any")
                    {
                        StringBuilder sb = new StringBuilder(Model._selectedpcode.Trim().ToUpper());
                        sb.Remove(5, sb.Length - 5);
                        _issues = _issues.Where(i => i.student.programcode.Trim().ToUpper().Contains(sb.ToString()));
                    }
                    if ((Model._date1 != null) && (Model._date2 != null))
                    {
                        if (Model._date1 > Model._date2)
                        {
                            _issues = _issues.Where(i => i.date >= Model._date2 && i.date <= Model._date1);
                        }
                        else if (Model._date2 > Model._date1)
                        {
                            _issues = _issues.Where(i => i.date <= Model._date2 && i.date >= Model._date1);
                        }
                        else
                        {
                            _issues = _issues.Where(i => i.date == Model._date1);
                        }
                    }
                    List<IssuesPOCO> _issue = new List<IssuesPOCO>();
                    foreach (issue i in _issues.OrderByDescending(e => e.date))
                    {
                        IssuesPOCO temp = new IssuesPOCO();
                        temp.IssueID = i.issueid;
                        temp.Name = i.issuename;
                        temp.Date = ConvertToUnixTimestamp(i.date).ToString();
                        temp.Status = i.status;
                        temp.Urgency = i.urgency;

                        _issue.Add(temp);
                    }
                    Model._issue = _issue;
                    Model._employee = employees;
                    Model._catagories = catagories;
                    Model._programcode = collection;

                    return View(Model);
                }
                return View(Model);
            }
            catch (Exception ex)
            {
                return View(Model);
            }
        }
예제 #2
0
        private void Fixupcatagory1(catagory previousValue)
        {
            if (IsDeserializing)
            {
                return;
            }

            if (previousValue != null && previousValue.issues.Contains(this))
            {
                previousValue.issues.Remove(this);
            }

            if (catagory1 != null)
            {
                if (!catagory1.issues.Contains(this))
                {
                    catagory1.issues.Add(this);
                }

                catagory = catagory1.catagory1;
            }
            if (ChangeTracker.ChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("catagory1")
                    && (ChangeTracker.OriginalValues["catagory1"] == catagory1))
                {
                    ChangeTracker.OriginalValues.Remove("catagory1");
                }
                else
                {
                    ChangeTracker.RecordOriginalValue("catagory1", previousValue);
                }
                if (catagory1 != null && !catagory1.ChangeTracker.ChangeTrackingEnabled)
                {
                    catagory1.StartTracking();
                }
            }
        }
        //
        // GET: /Issue/
        /// <summary>
        /// Ensures tha field have the proper information
        /// </summary>
        /// <returns></returns>
        public ViewResult Index()
        {
            try
            {
                var issues = db.issues.Include("student");
                List<IssuesPOCO> _issues = new List<IssuesPOCO>();
                foreach (issue i in issues.OrderByDescending(e => e.date))
                {
                    IssuesPOCO temp = new IssuesPOCO();
                    temp.IssueID = i.issueid;
                    temp.Name = i.issuename;
                    temp.Date = ConvertToUnixTimestamp(i.date).ToString();
                    temp.Status = i.status;
                    temp.Urgency = i.urgency;

                    _issues.Add(temp);
                }
                var program = db.programs;
                var employee = db.employees;
                List<String> employees = new List<String>();
                employees.Add("Any");
                foreach (employee emp in employee)
                {
                    employees.Add(emp.employeeid.Trim() + " - " + emp.fname.Trim() + " " + emp.lname.Trim());
                }
                List<catagory> catagories = new List<catagory>();
                catagory cat = new catagory() { catagory1 = "Any" };
                catagories.Add(cat);
                catagories.AddRange(db.catagories);
                List<String> collection = new List<String>();
                collection.Add("Any");
                foreach (program prog in program)
                {
                    collection.Add(prog.programcode.ToString().Trim() + " - " + prog.programname.ToString().Trim());
                }
                IndexIssueRequestModel Model = new IndexIssueRequestModel() { _issue = _issues.OrderByDescending(i => i.Status), _employee = employees, _catagories = catagories, _date1 = issues.OrderByDescending(i => i.date).First().date, _date2 = issues.OrderBy(i => i.date).First().date, _programcode = collection };
                return View(Model);
            }
            catch (Exception ex)
            {
                return View();
            }
        }