コード例 #1
0
ファイル: Delete.cshtml.cs プロジェクト: ronripp/CStat
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            //var sms = new CSSMS(_hostEnv, _configuration);
            //sms.SendMessage("12037700732", "Hello there Test2");

            if (id == null)
            {
                return(NotFound());
            }

            Task = await _context.Task.FindAsync(id);

            try
            {
                if (Task != null)
                {
                    _context.Task.Remove(Task);
                    await _context.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                _ = e;
            }
            return(RedirectToPage("./Index"));
        }
コード例 #2
0
        public ActionResult OnPostMarkComplete()
        {
            int taskId = int.Parse(this.Request.Form.FirstOrDefault(kv => kv.Key == "taskId").Value);

            if (taskId > 0)
            {
                var   taskData = TaskData.ReadTaskData(hostEnv, taskId, -1);
                CTask task     = _context.Task.First(t => (t.Id == taskId));
                if ((task != null) && (taskData != null))
                {
                    taskData.PercentComplete = 100;
                    taskData.Write(hostEnv);
                    task.GetTaskStatus(out CTask.eTaskStatus status, out CTask.eTaskStatus reason, out int pctComp);
                    pctComp = 100;
                    status  = CTask.eTaskStatus.Completed;
                    reason  = CTask.eTaskStatus.Job_Done;
                    task.SetTaskStatus((CTask.eTaskStatus)status, (CTask.eTaskStatus)reason, (int)pctComp);
                    try
                    {
                        taskData.Write(hostEnv);
                        _context.Attach(task).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                        _context.SaveChanges();
                        return(this.Content("Success"));
                    }
                    catch { }
                }
            }
            return(this.Content("Failed"));
        }
コード例 #3
0
ファイル: AutoGen.cs プロジェクト: ronripp/CStat
        public List <CTask> GetTemplateTasks(IWebHostEnvironment hstEnv, CStat.Models.CStatContext context, CTask tmpl, List <Event> events, DateRange lim)
        {
            List <CTask> taskList = new List <CTask>();

            if (tmpl.GetDueDates(events, out List <DateTimeEv> dueDateEvs, lim))
            {
                foreach (var dueDateEv in dueDateEvs)
                {
                    // Create new task and add it to the list
                    CTask task = new CTask();
                    task.ParentTaskId      = tmpl.Id;
                    task.Type              = 0;
                    task.Description       = tmpl.Description;
                    task.PlanLink          = tmpl.PlanLink;
                    task.EstimatedManHours = tmpl.EstimatedManHours;
                    task.Id                = 0;
                    task.PersonId          = tmpl.PersonId;
                    task.TotalCost         = tmpl.TotalCost;
                    task.EstimatedDoneDate = new DateTime(1900, 1, 1);
                    task.CommittedCost     = 0;
                    task.DueDate           = dueDateEv.dt;
                    task.EventId           = dueDateEv.eventID;
                    task.SetTaskStatus(CTask.eTaskStatus.Not_Started, CTask.eTaskStatus.Unknown, 0);
                    task.Priority       = (int)tmpl.Priority;
                    task.RequiredSkills = tmpl.RequiredSkills;
                    taskList.Add(task);
                }
            }

            return(taskList);
        }
コード例 #4
0
        //private TaskData CreateTestTaskData ()
        //{
        //    TaskData tData = new TaskData(task.Id)
        //    {
        //        state = (int)CTask.eTaskStatus.Paused,
        //        reason = (int)CTask.eTaskStatus.Need_Funds,
        //        Desc = "The same came to Jesus by night, and said unto him, Rabbi, we know that thou art a teacher come from God: for no man can do these miracles that thou doest, except God be with him.             Jesus answered and said unto him, Verily, verily, I say unto thee, Except a man be born again, he cannot see the kingdom of God. Nicodemus saith unto him, How can a man be born when he is old ? can he enter the second time into his mother's womb, and be born? Jesus answered, Verily, verily, I say unto thee, Except a man be born of water and of the Spirit, he cannot enter into the kingdom of God. That which is born of the flesh is flesh; and that which is born of the Spirit is spirit. Marvel not that I said unto thee, Ye must be born again. The wind bloweth where it listeth, and thou hearest the sound thereof, but canst not tell whence it cometh, and whither it goeth: so is every one that is born of the Spirit."
        //    };

        //    Pic pic = new Pic(126, 1, "This is the title description for Pic 1", "Images/Img_126_1.jpg");
        //    tData.pics.Add(pic);
        //    pic = new Pic(126, 2, "This is the title description for Pic 22", "Images/Img_126_2.jpg");
        //    tData.pics.Add(pic);
        //    pic = new Pic(126, 3, "This is the title description for Pic 333", "Images/Img_126_3.jpg");
        //    tData.pics.Add(pic);
        //    return tData;
        //}

        private void InitializeTask(int tid = 0)
        {
            task     = new CTask();
            taskData = new TaskData();
            if (tid == -1)
            {
                // Initialize Template
                task.Type            |= (int)CTask.eTaskType.Template;
                IsTemplate            = true;
                taskData.FixedDueDate = true;
                tid = 0;
            }
            else
            {
                task.Type = 0;
            }

            task.Description       = "";
            task.EstimatedManHours = 0;
            task.Id                = tid;
            task.PersonId          = null;
            task.TotalCost         = 0;
            task.EstimatedDoneDate = new DateTime(1900, 1, 1);
            task.CommittedCost     = 0;
            task.SetTaskStatus(CTask.eTaskStatus.Not_Started, CTask.eTaskStatus.Unknown, 0);
            task.Priority       = (int)CTask.ePriority.High;
            task.RequiredSkills = "";
        }
コード例 #5
0
 public CreateModel(CStat.Models.CStatContext context, IWebHostEnvironment hstEnv, IConfiguration config, UserManager <CStatUser> userManager)
 {
     _context     = context;
     hostEnv      = hstEnv;
     _config      = config;
     _userManager = userManager;
     taskData     = new TaskData();
     task         = new CTask();
 }
コード例 #6
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Task = await _context.Task
                   .Include(t => t.Blocking1)
                   .Include(t => t.Blocking2)
                   .Include(t => t.Church)
                   .Include(t => t.Person).FirstOrDefaultAsync(m => m.Id == id);

            if (Task == null)
            {
                return(NotFound());
            }
            return(Page());
        }
コード例 #7
0
ファイル: Edit.cshtml.cs プロジェクト: ronripp/CStat
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Task = await _context.Task
                   .Include(t => t.Blocking1)
                   .Include(t => t.Blocking2)
                   .Include(t => t.Church)
                   .Include(t => t.Person).FirstOrDefaultAsync(m => m.Id == id);

            if (Task == null)
            {
                return(NotFound());
            }
            ViewData["Blocking1Id"] = new SelectList(_context.Task, "Id", "Description");
            ViewData["Blocking2Id"] = new SelectList(_context.Task, "Id", "Description");
            ViewData["ChurchId"]    = new SelectList(_context.Church, "Id", "Affiliation");
            ViewData["PersonId"]    = new SelectList(_context.Person, "Id", "FirstName");
            return(Page());
        }
コード例 #8
0
        public async Task DoWork(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                DateTime enow     = PropMgr.ESTNow;
                DateTime expected = new DateTime(enow.Year, enow.Month, enow.Day, 3, 0, 0);
                DateTime lastW    = (_csSettings.LastTaskUpdate != null) ? _csSettings.LastTaskUpdate : new DateTime(2020, 1, 1);
#if DEBUG
                double MinWait = 0;                                                                              // for testing
#else
                double MinWait = 720;                                                                            // 12 hrs
#endif
                if (((enow - lastW).TotalMinutes >= MinWait) || (Math.Abs((enow - expected).TotalMinutes) < 65)) // done not more than twice a day and covers DST change with delay/offset
                {
                    // Check Stock for possibly needed items
                    OrderedEvents         ordEvs         = new OrderedEvents(_context);
                    IList <InventoryItem> InventoryItems = _context.InventoryItem.Include(i => i.Inventory).Include(i => i.Item).ToList();
                    foreach (var invIt in InventoryItems)
                    {
                        if (IndexInvModel.MayNeedItem(_context, invIt, ordEvs))
                        {
                            // Item likely needs to be ordered. Mark as needed.
                            if (invIt.State == IndexInvModel.STOCKED_STATE)
                            {
                                invIt.State = IndexInvModel.NEEDED_STATE;
                                _context.Attach(invIt).State = EntityState.Modified;

                                try
                                {
                                    _context.SaveChanges();
                                    _csSettings.LastStockUpdate = PropMgr.ESTNow;
                                    _csSettings.Save();
                                    await Task.Run(() => IndexInvModel.NotifyNeedAsync(_hostEnv, _configuration, _userManager, "CStat:Stock> Needed : " + invIt.Item.Name, true)); // potentially clean Message log
                                }
                                catch (DbUpdateConcurrencyException)
                                {
                                    continue;
                                }
                            }
                        }
                    }

                    // Check for new Tasks
                    AutoGen ag = new AutoGen(_context);
                    _csSettings.LastTaskUpdate = PropMgr.ESTNow;
                    _csSettings.Save();
                    ag.GenTasks(_hostEnv);

                    // Notify users Tasks Due
                    CTask.NotifyUserTaskDue(_hostEnv, _configuration, _userManager, _context, 24, true); // Potentially clean log

                    // Persist Daily Reading and Notify if needed for Propane
                    PropaneMgr pmgr = new PropaneMgr(_hostEnv, _configuration, _userManager);
                    pmgr.CheckValue(pmgr.GetTUTank(true)); // get value, log to file and check

                    // Check for any unexpected propane usage (not potentially impacted from events) from recent daily usage
                    var plList = pmgr.GetAll(3);
                    var plCnt  = plList.Count;
                    if (plCnt > 1)
                    {
                        for (int i = 0; i < plCnt - 1; ++i)
                        {
                            var plStart   = plList[i];
                            var plEnd     = plList[i + 1];
                            var dateRange = new DateRange(plStart.ReadingTime, plEnd.ReadingTime);

                            var evList = ag.GetImpactingEvents(dateRange);
                            if (evList.Count == 0) // no impacting events
                            {
                                var totalHrs = dateRange.TotalHours();
                                if ((totalHrs > 0) && _csSettings.GetPropaneProperties(out double tankGals, out double pricePerGal))
                                {
                                    var totalGals = ((plStart.LevelPct - plEnd.LevelPct) / 100) * tankGals;
                                    if ((totalGals / totalHrs) > ((double)2 / 24)) // averaging more than 2 gals/day?
                                    {
                                        // Send a one time alert (allowResend = false)
                                        CSSMS sms = new CSSMS(_hostEnv, _configuration, _userManager);
                                        sms.NotifyUsers(CSSMS.NotifyType.EquipNT, "CStat:Equip> " + "Non Event Propane Usage was " + totalGals.ToString("0.##") + " gals. during " + totalHrs.ToString("0.#") + " hours starting " +
                                                        plStart.ReadingTime.Month + "/" + plStart.ReadingTime.Day + "/" + plStart.ReadingTime.Year % 100, false, true); // potentially clean Message Log
                                    }
                                }
                            }
                        }
                    }

                    // Check for new EMails to store
                    CSEMail.SaveEMails(_configuration, _userManager);

                    // Check/Truncate Size of Arduino file
                    ArdMgr amgr = new ArdMgr(_hostEnv, _configuration, _userManager);
                    amgr.GetAll(true);

                    // Clean/{Reset to full view} Camera
                    using (var ptz = new PtzCamera())
                    {
                        ptz.Cleanup(_hostEnv);
                    }

                    _logger.LogInformation($"CStat Daily Updates Completed at {PropMgr.ESTNow}");
                }

                // Run again at 3:00 AM
                DateTime now          = PropMgr.ESTNow;
                DateTime tom          = now.AddDays(1);
                DateTime start        = new DateTime(tom.Year, tom.Month, tom.Day, 3, 0, 0); // Restart at 3:00 AM tomorrow
                int      MSecsToStart = (int)Math.Round((start - now).TotalMilliseconds);
                await System.Threading.Tasks.Task.Delay(MSecsToStart, stoppingToken);
            }
        }
コード例 #9
0
ファイル: AutoGen.cs プロジェクト: ronripp/CStat
        public bool GenTasks(IWebHostEnvironment hstEnv, int tmplId = -1)
        {
            // Get a List of Template Tasks for a specific template id(when template task is changed) ...or... ALL template tasks (tmplId = -1) when looking to generate tasks in general.
            var TemplateTasks = (tmplId != -1) ? _context.Task.Include(t => t.Person).Where(t => ((t.Type & (int)CTask.eTaskType.Template) != 0) && (t.Id == tmplId)).ToList() :
                                _context.Task.Include(t => t.Person).Where(t => (t.Type & (int)CTask.eTaskType.Template) != 0).OrderBy(t => t.Priority).ToList();

            // Get the range limit of time to possibly create new tasks and a list of events that fully or partially overlap this range limit of time
            DateTime now       = PropMgr.ESTNow;
            DateTime startTime = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0);
            DateTime endTime   = startTime.AddMonths(6);
            //DateTime endTime = new DateTime(startTime.Year+1, 12, 31, 23, 59, 59);
            DateRange    lim    = new DateRange(startTime, endTime);
            List <Event> evList = GetEvents(lim);

            List <CTask> AllNewTaskList = new List <CTask>(); // Create a list for collecting all potentially new tasks created for all templates in TemplateTasks

            // Determine what needs to be Auto generated
            foreach (var tmpl in TemplateTasks)
            {
                // Get a list of existing tasks create from the specific template : tmpl
                List <CTask> curCreatedTasks = _context.Task.Include(t => t.Person).Where(t => t.ParentTaskId.HasValue && ((t.ParentTaskId == tmpl.Id) || (t.Description == tmpl.Description))).ToList();

                // Filter out new, created tasks : n that already exist : Having the {same_task_id ...or... same_description} ...AND... {same Year, Month, Day } ...AND... {newlyCreatedTime >= currExistingTime}
                // Note : to be safe, we keep newlyCreatedTime earlier times than currExistingTime and may add as a duplicate in some special cases.
                List <CTask> newCreatedTasks = GetTemplateTasks(hstEnv, _context, tmpl, evList, lim).Where(n => !curCreatedTasks.Any(c => ((c.ParentTaskId == n.ParentTaskId) || (c.Description == n.Description)) &&
                                                                                                                                     c.DueDate.HasValue && n.DueDate.HasValue && (c.DueDate.Value.Year == n.DueDate.Value.Year) && (c.DueDate.Value.Month == n.DueDate.Value.Month) &&
                                                                                                                                     (c.DueDate.Value.Day == n.DueDate.Value.Day) && n.DueDate >= c.DueDate)).ToList();

                //TBD : Do not regen a task that is already closed

                // Make sure the newly filtered potential tasks are assigned to a person
                // NOTE : we cannot rely on tmpl as the only parent tasks as newCreatedTasks may contain other tasks not having t.ParentTaskId = tmpl.Id
                if (newCreatedTasks.Count > 0)
                {
                    // ensure each newCreatedTask is assigned to someone and that person is avaiable
                    // Cache Task Data by task id
                    var TDCache = new Dictionary <int, TaskData>();
                    var PIDList = new List <int>();
                    foreach (var t in newCreatedTasks)
                    {
                        TaskData taskData;
                        if (!TDCache.TryGetValue(t.Id, out taskData))
                        {
                            taskData      = TaskData.ReadTaskData(hstEnv, t.Id, -1);
                            TDCache[t.Id] = taskData;
                        }

                        // For each newCreatedTask, check for a person who is unavailable and if unavailable, nullify person id and person;
                        if (t.PersonId.HasValue && !PIDList.Contains(t.PersonId.Value))
                        {
                            int pid = t.PersonId.Value;
                            PIDList.Add(pid);
                            Person person = (Person)_context.Person.First(p => p.Id == pid);
                            if ((person != null) && person.Roles.HasValue && (((long)person.Roles & (long)Person.TitleRoles.Unavailable) != 0))
                            {
                                t.PersonId = null;
                                t.Person   = null;
                            }
                        }

                        if (!t.PersonId.HasValue || (t.PersonId <= 0))
                        {
                            // Determine person from roles
                            var pid = CTask.ResolvePersonId(_context, taskData.Role1, taskData.Role2, taskData.Role3);
                            if (pid.HasValue && (pid > 0))
                            {
                                t.PersonId = pid;
                                t.SetType(CTask.eTaskType.AutoPersonID);
                            }
                        }
                    }
                }

                // Filter out tasks (completed or not completed that already exist.
                foreach (var nt in newCreatedTasks) // This loop may be redundant. It was added to fix a problem that ultimately was related to changed Due Dates. TBD : Check if it can be removed.
                {
                    if (nt.ParentTaskId.HasValue && (nt.ParentTaskId.Value > 0) && nt.DueDate.HasValue)
                    {
                        if (_context.Task.Any(t => t.ParentTaskId.HasValue && (t.ParentTaskId.Value == nt.ParentTaskId.Value) && t.DueDate.HasValue && (t.DueDate.Value.Date == nt.DueDate.Value.Date)))
                        {
                            continue;           // Child Task with due date already exist. Skip.
                        }
                        AllNewTaskList.Add(nt); // Add needed new task
                    }
                }
            }

            // Search for any existing tasks that are assigned to a person who is now unavailable
            List <CTask> unavailTasks = _context.Task.Include(t => t.Person).Where(t => t.ParentTaskId.HasValue && (t.ParentTaskId.Value > 0) && t.PersonId.HasValue && t.Person.Roles.HasValue && (((long)t.Person.Roles & (long)Person.TitleRoles.Unavailable) != 0)).ToList();

            foreach (var ut in unavailTasks)
            {
                TaskData utd = TaskData.ReadTaskData(hstEnv, ut.ParentTaskId.Value, -1);
                ut.PersonId = CTask.ResolvePersonId(_context, utd.Role1, utd.Role2, utd.Role3);  // Reassign from the unavailable person to someone else
                _context.Attach(ut).State = EntityState.Modified;
                try
                {
                    _context.SaveChanges();
                }
                catch { }
            }

            // TBD: Maintain AutoPersonID state properly.

            // Check for duplicates by same description and same day before Adding to DB.
            var    OrdTasks = AllNewTaskList.OrderBy(t => t.Description).ThenBy(t => t.DueDate);
            string lastDesc = "";
            int    lastYear = -1, lastMonth = -1, lastDay = -1;

            foreach (var t in OrdTasks)
            {
                bool bSkip = (t.Description == lastDesc) && t.DueDate.HasValue && (t.DueDate.Value.Year == lastYear) && (t.DueDate.Value.Month == lastMonth) && (t.DueDate.Value.Day == lastDay);
                lastDesc  = t.Description;
                lastYear  = t.DueDate.Value.Year;
                lastMonth = t.DueDate.Value.Month;
                lastDay   = t.DueDate.Value.Day;

                if (!bSkip)
                {
                    _context.Task.Add(t);
                    _context.SaveChanges();
                }
            }
            return(true);
        }
コード例 #10
0
        public IActionResult OnGet(int?id)
        {
            int tid = !id.HasValue ? tid = 0 : id.Value;
            int res = 0;

            if (tid <= 0)
            {
                // Create new task
                InitializeTask(tid);
                _context.Task.Add(task);
                res = _context.SaveChanges();
            }
            else
            {
                task = _context.Task.FirstOrDefault(m => m.Id == tid);
                if ((task != null) && (tid == task.Id))
                {
                    IsTemplate = (task.Type & (int)CTask.eTaskType.Template) != 0;
                    taskData   = TaskData.ReadTaskData(hostEnv, tid, task.ParentTaskId.HasValue ? task.ParentTaskId.Value : -1);
                    if ((task.DueDate == null) && !IsTemplate)
                    {
                        task.DueDate = task.EstimatedDoneDate; // temporary for editing purpose
                    }
                    else
                    {
                        taskData.FixedDueDate = true;
                    }

                    task.GetTaskStatus(out eTaskStatus state, out eTaskStatus reason, out int PercentComplete);
                    taskData.state           = (int)state;
                    taskData.reason          = (int)reason;
                    taskData.PercentComplete = PercentComplete;

                    if ((task.Type & (int)CTask.eTaskType.Template) != 0)
                    {
                        // Initialize Template Type members
                        CTask.eTaskType CreateTaskDue;
                        CTask.eTaskType CreateTaskEach;
                        int             CreateTaskDueVal;
                        task.GetTaskType(out CreateTaskDue, out CreateTaskEach, out CreateTaskDueVal);
                        taskData.CreateTaskDue  = (int)CreateTaskDue;
                        taskData.CreateTaskEach = (int)CreateTaskEach;
                        taskData.TillDay        = ((taskData.CreateTaskEach == (int)CTask.eTaskType.Day_from_Due_till) && task.EstimatedDoneDate.HasValue) ?
                                                  task.EstimatedDoneDate.Value.Month + "/" + task.EstimatedDoneDate.Value.Day : "";
                        switch (CreateTaskDue)
                        {
                        case CTask.eTaskType.Day_Of_Week_SunMon:
                            taskData.CreateTaskDueVal = ((CreateTaskDueVal >= 1) && (CreateTaskDueVal <= 7)) ? TaskArrs.weekDays[CreateTaskDueVal] : "";
                            break;

                        //case CTask.eTaskType.At_Date:
                        //    if (CreateTaskDueVal > (1 << 5))
                        //    {
                        //        int day = CreateTaskDueVal & 0x1F;
                        //        int month = CreateTaskDueVal >> 5;
                        //        taskData.CreateTaskDueVal = month.ToString() + "/" + day;
                        //    }
                        //    else
                        //        taskData.CreateTaskDueVal = "";
                        //    break;

                        default:
                            taskData.CreateTaskDueVal = CreateTaskDueVal.ToString();
                            break;
                        }
                    }
                }
                else
                {
                    InitializeTask(tid);
                }
            }

            IList <SelectListItem> sList = Enum.GetValues(typeof(CTask.eTaskStatus)).Cast <CTask.eTaskStatus>().Where(e => (int)e < (int)CTask.eTaskStatus.Need_Funds).Select(x => new SelectListItem {
                Text = x.ToString().Replace("_", " "), Value = ((int)x).ToString()
            }).ToList();

            ViewData["State"] = sList;
            IList <SelectListItem> rList = Enum.GetValues(typeof(CTask.eTaskStatus)).Cast <CTask.eTaskStatus>().Where(e => (int)e >= (int)CTask.eTaskStatus.Need_Funds).Select(x => new SelectListItem {
                Text = x.ToString().Replace("_", " "), Value = ((int)x).ToString()
            }).ToList();

            ViewData["Reason"] = rList;

            IList <SelectListItem> dueList = Enum.GetValues(typeof(CTask.eTaskType)).Cast <CTask.eTaskType>().Where(e => ((int)e >= (int)CTask.eTaskType.Before_Start) && ((int)e <= (int)CTask.eTaskType.Day_Of_Week_SunMon)).Select(x => new SelectListItem {
                Text = x.ToString().Replace("_", " "), Value = ((int)x).ToString()
            }).ToList();

            ViewData["CreateTaskDue"] = dueList;

            IList <SelectListItem> eachList = Enum.GetValues(typeof(CTask.eTaskType)).Cast <CTask.eTaskType>().Where(e => ((int)e >= (int)CTask.eTaskType.Retreat_Event) && ((int)e < (int)CTask.eTaskType.Num_Start_Date)).Select(x => new SelectListItem {
                Text = x.ToString().Replace("_", " ").Replace(" n ", "/"), Value = ((int)x).ToString()
            }).ToList();

            ViewData["CreateTaskEach"] = eachList;

            IList <SelectListItem> pList = Enum.GetValues(typeof(CTask.ePriority)).Cast <CTask.ePriority>().Select(x => new SelectListItem {
                Text = x.ToString().Replace("_", " "), Value = ((int)x).ToString()
            }).ToList();

            ViewData["Priority"] = pList;

            ViewData["Blocking1Id"] = new SelectList(_context.Task, "Id", "Description");
            ViewData["Blocking2Id"] = new SelectList(_context.Task, "Id", "Description");
            ViewData["ChurchId"]    = new SelectList(_context.Church, "Id", "Affiliation");

            IList <SelectListItem> personList = _context.Person.OrderBy(p => p.LastName).ThenBy(p1 => p1.FirstName).Where(p => (p.SkillSets & (long)eSkillsAbbr.WRK) != 0).Select(p2 => new SelectListItem {
                Text = p2.FirstName + " " + p2.LastName, Value = p2.Id.ToString()
            }).ToList <SelectListItem>();

            personList.Insert(0, new SelectListItem(" ", "-1"));
            ViewData["PersonId"] = personList;

            IList <SelectListItem> trList = Enum.GetValues(typeof(Person.TitleRoles)).Cast <Person.TitleRoles>().Select(x => new SelectListItem {
                Text = x.ToString().Replace("_", " "), Value = ((int)x).ToString()
            }).ToList();

            ViewData["TitleRoles"] = new SelectList(trList, "Value", "Text");

            return(Page());
        }