Example #1
0
        public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            var taskViewData = new TaskViewData();
            int?id           = null;

            if (controllerContext.RouteData.Values["Id"].ToString().Length > 0)
            {
                id = Int32.Parse(controllerContext.RouteData.Values["Id"].ToString());
            }

            using (var db = new TrackerDataContext())
            {
                if (id != null)
                {
                    taskViewData.Task = db.Task.GetByKey(id.Value);
                    taskViewData.Task.Detach();
                }
                else
                {
                    taskViewData.Task = new Task();
                }
            }


            return(taskViewData);
        }
Example #2
0
        public TaskViewData GetData(Task task)
        {
            var taskViewData = new TaskViewData();

            if (null == task)
            {
                task = new Task();
            }

            taskViewData.Task = task;

            taskViewData.AssignedUsers = UIHelper.GetUserSelectList(task.AssignedId);
            taskViewData.CreatedUsers  = UIHelper.GetUserSelectList(task.CreatedId);
            taskViewData.Statuses      = UIHelper.GetStatusSelectList(task.Status);
            taskViewData.Priorities    = UIHelper.GetPrioritySelectList(task.Priority);

            using (var db = new TrackerDataContext())
            {
                db.ObjectTrackingEnabled = false;
                taskViewData.Audits      = UIHelper.TransformAudits(db.Audit.ByTaskId(task.Id).OrderByDescending(a => a.Date).ToList());
            }
            return(taskViewData);
        }