Ejemplo n.º 1
0
        // GET: MyTasks
        public async Task <IActionResult> Index(string myTaskAsignee, string searchString)
        {
            if (UsersController.logged_user.username == "None")
            {
                return(RedirectToAction("Privacy", "Home"));
            }

            IQueryable <string> asigneeQuery = from m in _context.MyTask
                                               orderby m.Asignee
                                               select m.Asignee;

            var myTasks = from m in _context.MyTask select m;

            if (!string.IsNullOrEmpty(searchString))
            {
                myTasks = myTasks.Where(s => s.Project.Contains(searchString));
            }

            if (!string.IsNullOrEmpty(myTaskAsignee))
            {
                myTasks = myTasks.Where(x => x.Asignee == myTaskAsignee);
            }

            var myTaskAsigneeVM = new MyTaskAsigneeViewModel
            {
                Asignees = new SelectList(await asigneeQuery.Distinct().ToListAsync()),
                MyTasks  = await myTasks.ToListAsync()
            };

            return(View(myTaskAsigneeVM));
        }
Ejemplo n.º 2
0
        //GET : Dashboard
        public async Task <IActionResult> Dashboard(string name)
        {
            if (UsersController.logged_user == null)
            {
                return(RedirectToAction("Privacy", "Home")); //Privacy is used as default empty page
            }

            // Use LINQ to get list of genres.
            IQueryable <string> asigneeQuery = from m in _context.MyTask
                                               orderby m.Asignee
                                               select m.Asignee;

            var myTasks = from m in _context.MyTask
                          where m.Asignee == name || m.Owner == name
                          orderby m.Due_Date
                          select m;


            if (string.IsNullOrEmpty(name))
            {
                name = logged_user.username;
            }

            // myTasks = myTasks.Where(x => x.Asignee == name || x.Owner==name);

            var myTaskAsigneeVM = new MyTaskAsigneeViewModel
            {
                Asignees = new SelectList(await asigneeQuery.Distinct().ToListAsync()),
                MyTasks  = await myTasks.ToListAsync()
            };

            return(View(myTaskAsigneeVM));
        }
Ejemplo n.º 3
0
        // GET: MyTasks
        public async Task <IActionResult> Index(string myTaskTag, string location)
        {
            if (UsersController.logged_user == null)
            {
                return(RedirectToAction("Privacy", "Home"));
            }

            IQueryable <MyTask.TagType> tagsQuery = from m in _context.MyTask
                                                    orderby m.Tag
                                                    select m.Tag;


            var myTasks = from m in _context.MyTask select m;

            myTasks = myTasks.Where(asgn => asgn.Asignee == null);
            if (!string.IsNullOrEmpty(location))
            {
                myTasks = myTasks.Where(s => s.Location.Contains(location));
            }

            if (!string.IsNullOrEmpty(myTaskTag))
            {
                MyTask.TagType tag = (MyTask.TagType)Enum.Parse(typeof(MyTask.TagType), myTaskTag);
                myTasks = myTasks.Where(x => x.Tag == tag);
            }

            var myTaskAsigneeVM = new MyTaskAsigneeViewModel
            {
                Tags    = new SelectList(await tagsQuery.Distinct().ToListAsync()),
                MyTasks = await myTasks.ToListAsync()
            };

            return(View(myTaskAsigneeVM));
        }