Exemple #1
0
        // GET: BoardTasks/Delete/5
        public async Task <IActionResult> Delete(long?id)//View BoardTask delete page
        {
            bool userExists = CheckUser();

            if (!userExists)
            {
                return(RedirectToAction("Signin", "Account"));
            }
            if (id == null)
            {
                return(NotFound());
            }

            BoardTask boardTask = null;

            try
            {
                await Task.Run(() => {
                    boardTask = new BoardTaskUtils().GetBoardTask(_context, (long)id);
                });
            }
            catch (Exception) {
                return(NotFound());
            }

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

            return(View(boardTask));
        }
Exemple #2
0
        public async Task <IActionResult> EditBoardView([FromForm] BoardViewModel boardViewModel)
        {
            bool userExists = CheckUser();

            if (!userExists)
            {
                return(RedirectToAction("Signin", "Account"));
            }
            if ((boardViewModel.DateCreated.CompareTo(boardViewModel.DateFinished)) > 0)
            {
                ModelState.AddModelError("DateFinished", "Дата окончния меньше текущей");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var boardtask = new BoardTaskUtils().GetBoardTask(_context, boardViewModel.Id);

                    boardtask.ContentTask  = boardViewModel.Content;
                    boardtask.DateFinished = boardViewModel.DateFinished;

                    await Task.Run(() => {
                        new GeneralActions().UpdateObject(_context, boardtask);
                    });
                }
                catch (Exception)
                {
                    if (!BoardTaskExists(boardViewModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Details", "BoardTasks", new { id = boardViewModel.Id }));
            }

            return(RedirectToAction("Details", "BoardTasks", new { id = boardViewModel.Id }));
        }
Exemple #3
0
        // GET: BoardTasks/Details/5
        public async Task <IActionResult> Details(long?id) //Show one BoardTask and collection StageTasks
        {
            bool userExists = CheckUser();

            if (!userExists)
            {
                return(RedirectToAction("Signin", "Account"));
            }

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

            BoardTask boardTask = null;

            try
            {
                await Task.Run(() =>
                {
                    boardTask = new BoardTaskUtils().GetBoardTask(_context, (long)id);
                });
            }
            catch (Exception) {
                return(NotFound());
            }

            if (boardTask != null)
            {
                BoardViewModel board = new BoardViewModel();
                board.Content      = boardTask.ContentTask;
                board.Name         = boardTask.NameTask;
                board.Id           = boardTask.Id;
                board.DateCreated  = boardTask.DateCreated;
                board.DateFinished = boardTask.DateFinished;


                IEnumerable <StageTask> taskstages = null;

                try
                {
                    await Task.Run(() =>
                    {
                        taskstages = new StageUtils().GetStagesForTask(_context, boardTask.Id);
                    });
                }
                catch (Exception) {
                    return(NotFound());
                }

                BoardStageViewModel boardStageView = new BoardStageViewModel {
                    BoardView = board, StageTasks = taskstages
                };

                return(View(boardStageView));
            }
            else
            {
                return(NotFound());
            }
        }
Exemple #4
0
        public async Task <IActionResult> CreateStage([Bind("IdOwner,ContentStage,DateFinished")] StageTask stageTask, string date_create) //CreateStage
        {
            bool userExists = CheckUser();

            if (!userExists)
            {
                return(RedirectToAction("Signin", "Account"));
            }


            double localDate = Convert.ToDouble(date_create);

            stageTask.DateCreated = new DateTime(1970, 1, 1, 0, 0, 0).AddMilliseconds(localDate);

            // stageTask.DateCreated = ConvertStringToDateTime(date_create);
            //AddSeconds(localDate);

            BoardTask boardTask = null;

            try
            {
                await Task.Run(() =>
                {
                    boardTask = new BoardTaskUtils().GetBoardTask(_context, stageTask.IdOwner);
                });
            }
            catch (Exception)
            {
                return(NotFound());
            }
            if (boardTask == null)
            {
                return(NotFound());
            }


            if ((boardTask.DateFinished.CompareTo(stageTask.DateFinished)) < 0)
            {
                ModelState.AddModelError("DateFinished", "Дата окончния не может быть позже даты окончния задачи");
            }


            if ((stageTask.DateCreated.CompareTo(stageTask.DateFinished)) > 0)
            {
                ModelState.AddModelError("DateFinished", "Дата окончния меньше текущей");
            }

            if (ModelState.IsValid)
            {
                stageTask.NameStage = "Stage";

                try
                {
                    await Task.Run(() =>
                    {
                        new GeneralActions().AddNewObject(_context, stageTask);
                    });

                    return(RedirectToAction("Details", "BoardTasks", new { id = stageTask.IdOwner }));
                }
                catch (Exception) {
                    return(NotFound());
                }
            }
            ViewData["IdOwner"] = stageTask.IdOwner;
            return(View(stageTask));
        }
Exemple #5
0
        // GET: BoardTasks
        public async Task <IActionResult> Index()
        {
            long iduser;

            try
            {
                iduser = GetUserId();
            }
            catch
            {
                return(RedirectToAction("Signin", "Account"));
            }

            UserApp userApp = null;

            try
            {
                await Task.Run(() => {
                    userApp = new UserUtils().GetUserById(_context, iduser);
                });
            }
            catch (Exception) {
                return(NotFound());
            }

            if (userApp != null)
            {
                Cryptographer cryptographer = new Cryptographer().Create(userApp.Upassword);
                string        name          = cryptographer.Decode(userApp.FirstName);
                string        email         = cryptographer.Decode(userApp.Email);

                UserViewModel user = new UserViewModel();

                user.Id = userApp.Id;

                user.Name      = name.First().ToString().ToUpper() + String.Join("", name.Skip(1));
                user.Email     = email;
                user.ImagePath = userApp.ImagePath;

                IEnumerable <BoardTask> usertasks = null;

                try
                {
                    await Task.Run(() =>
                    {
                        usertasks = new BoardTaskUtils().GetUsersBoardTask(_context, userApp.Id);
                    });
                }
                catch (Exception) {
                    return(NotFound());
                }

                UserTaskViewModel userTaskView = new UserTaskViewModel {
                    UserView = user, BoardTasks = usertasks
                };

                return(View(userTaskView));
            }
            else
            {
                return(NotFound());
            }
        }