Пример #1
0
        public IActionResult OnGet(string id, string redirect)
        {
            // Authorization
            AuthorizationResult authorizationResult;

            if (!Authorization.CheckAuthorization(HttpContext, MySQL, HttpContext.Response, out authorizationResult))
            {
                return(StatusCode(authorizationResult.StatusCode));
            }
            LoginUser = authorizationResult.Account;

            if (!string.IsNullOrEmpty(id))
            {
                Library.Types.Task task = MySQL.Get <Library.Types.Task>(Convert.ToInt32(id));

                if (task.DONE)
                {
                    task.DONE = false;
                }
                else
                {
                    task.DONE = true;
                }

                MySQL.Update(task);
            }

            if (!String.IsNullOrEmpty(redirect))
            {
                return(Redirect(redirect));
            }
            return(Redirect("/Tasks"));
        }
Пример #2
0
        public IActionResult OnPostAsync()
        {
            if (String.IsNullOrEmpty(Title))
            {
                return(Page());
            }
            if (String.IsNullOrEmpty(Project))
            {
                return(Page());
            }

            Library.Types.Task task = new Library.Types.Task();
            task.TITLE      = Title;
            task.PROJECT    = Project;
            task.CREATOR    = LoginUserId;
            task.CREATED_AT = DateTime.Now;

            if (!(Assign == "Not set"))
            {
                foreach (Account CurrentAccount in MySQL.GetAll <Account>())
                {
                    if (CurrentAccount.USERNAME == Assign)
                    {
                        task.ASSIGNED = CurrentAccount.ID;
                    }
                }
            }

            MySQL.Insert(task);

            return(Redirect("/Tasks"));
        }
Пример #3
0
        public IActionResult OnGet(int?id, string mode, string done)
        {
            // Authorization
            AuthorizationResult authorizationResult;

            if (!Authorization.CheckAuthorization(HttpContext, MySQL, HttpContext.Response, out authorizationResult))
            {
                return(StatusCode(authorizationResult.StatusCode));
            }

            if (String.IsNullOrEmpty(Convert.ToString(id)))
            {
                IEnumerable <Library.Types.Task> AllTasks;
                if (!(done == "true"))
                {
                    AllTasks = MySQL.Query <Library.Types.Task>("SELECT * FROM tasks WHERE DONE=FALSE;");
                }
                else
                {
                    AllTasks = MySQL.GetAll <Library.Types.Task>();
                }
                switch (mode)
                {
                case "created":
                    foreach (Library.Types.Task CurrentTask in AllTasks)
                    {
                        if (CurrentTask.CREATOR.Equals(authorizationResult.Account.ID))
                        {
                            Tasks.Add(CurrentTask);
                        }
                    }
                    break;

                case "assigned":
                    foreach (Library.Types.Task CurrentTask in AllTasks)
                    {
                        if (CurrentTask.ASSIGNED.Equals(authorizationResult.Account.ID))
                        {
                            Tasks.Add(CurrentTask);
                        }
                    }
                    break;

                case "me":
                    foreach (Library.Types.Task CurrentTask in AllTasks)
                    {
                        if (CurrentTask.ASSIGNED.Equals(authorizationResult.Account.ID))
                        {
                            Tasks.Add(CurrentTask); break;
                        }
                        if (CurrentTask.CREATOR.Equals(authorizationResult.Account.ID))
                        {
                            Tasks.Add(CurrentTask);
                        }
                    }
                    break;

                default:
                    Tasks = AllTasks.ToList();
                    break;
                }
            }
            else
            {
                Task = MySQL.Get <Library.Types.Task>(id);
            }

            foreach (Account CurrentAccount in MySQL.GetAll <Account>())
            {
                Accounts.Add(CurrentAccount.ID, CurrentAccount);
            }
            AllUsers = MySQL.GetAll <Account>();

            return(Page());
        }