Exemplo n.º 1
0
        public ActionResult Index(long userId)
        {
            if (WebSettingsConfig.Instance.IsSectionForbidden(SectionId.UserTasks))
            {
                return(RedirectToAction("Index", RouteConfig.MAIN_CONTROLLER_NAME));
            }

            RepositoryFactory   repositoryFactory   = WebSettingsConfig.Instance.GetRepositoryFactory();
            UserTasksRepository userTasksRepository = repositoryFactory.CreateUserRepository(userId);
            List <UserTask>     tasks = userTasksRepository.GetTasks();

            HttpCookie newTaskCookie = HttpContext.Request.Cookies[TASK_COOKIE_NAME];
            string     taskId        = null;

            if (newTaskCookie != null)
            {
                taskId = newTaskCookie.Value;
                RemoveTaskCookie();
            }

            BanRepository banRepository = repositoryFactory.GetBanRepository();
            var           banHelper     = new BanHelper(Request);
            bool          isBanned      = banHelper.IsBanned(SectionId.UserTasks, userId, banRepository);

            var model = new UserTasksModel(taskId, tasks, isBanned);

            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult Create(UserTasksModel model)
        {
            try
            {
                //Create TaskManager instance with user credentials.
                TaskManager taskManager = new TaskManager(model.User.TaskCreatorEmailID, model.User.Password);

                //Call create task method
                taskManager.CreateTask(model.NewTask.TaskTitle, model.NewTask.TaskMessage, model.NewTask.TaskStartDate);

                //Get all tasks
                model.Tasks = taskManager.GetAllTasks().Select(task => new TaskModel {
                    TaskTitle     = task.Subject,
                    TaskMessage   = task.Body.Text,
                    TaskStartDate = task.DateTimeCreated
                }).ToList();

                return(PartialView("Tasks", model));
            }
            catch
            {
                return(PartialView("Tasks", model));
            }
        }
Exemplo n.º 3
0
 public void CreateUserTask(UserTasksModel task)
 {
     _db.UserTasks.Add(task);
     _db.SaveChanges();
 }