Пример #1
0
        private ActionResult UsersView(string status, string role)
        {
            User loggedUser       = Session["user"] as User;
            var  defaultDocuments = Session[$"{status}Documents"] as Dictionary <string, DocumentsRepository>;

            if (loggedUser == null || defaultDocuments == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var RoleId = loggedUser.Roles.FirstOrDefault(r => r.Name.Equals(role))?.Id ?? 0;

            UserTaskView userTaskView = new UserTaskView()
            {
                UserId = loggedUser.Id,
                RoleId = RoleId
            };

            DocumentsRepository pendingDocuments = defaultDocuments[role];

            userTaskView.Documents = pendingDocuments.Get();


            return(View("UserTasks", userTaskView));
        }
Пример #2
0
        public static UserTaskView GetUserTaskForUserView(Guid appUserId, Guid userTaskId)
        {
            ApplicationDbContext db   = new ApplicationDbContext();
            UserTaskView         view = GetUserTaskForUserView(db, appUserId, userTaskId);

            db.Dispose();
            return(view);
        }
Пример #3
0
        public static UserTaskView GetUserTaskForUserView(ApplicationDbContext db, Guid appUserId, Guid userTaskId)
        {
            List <UserTaskView> userTasksForUserView = UserTaskViewHelpers.GetUserTasksForUserView(db, appUserId);

            UserTaskView userTaskForUserView = (from u in userTasksForUserView
                                                where u.UserTaskId == userTaskId
                                                select u).FirstOrDefault();

            return(userTaskForUserView);
        }
Пример #4
0
        public static List <UserTaskView> GetUserTasksForUserView(ApplicationDbContext db, Guid appUserId)
        {
            List <UserTaskView> userTasksForUserView = new List <UserTaskView>();

            List <UserTask> userTasksForUser = UserTaskHelpers.GetUserTasksForUser(db, appUserId);

            foreach (UserTask userTaskForUser in userTasksForUser)
            {
                AppUser appUser = null;
                Branch  branch  = null;

                switch (userTaskForUser.TaskType)
                {
                case TaskTypeEnum.UserOnHold:
                    appUser = AppUserHelpers.GetAppUser(db, userTaskForUser.ReferenceKey);
                    break;

                case TaskTypeEnum.BranchOnHold:
                    branch = BranchHelpers.GetBranch(db, userTaskForUser.ReferenceKey);
                    break;
                }

                UserTaskView userTaskForUserView = new UserTaskView()
                {
                    UserTaskId       = userTaskForUser.UserTaskId,
                    TaskType         = userTaskForUser.TaskType,
                    TaskDescription  = userTaskForUser.TaskDescription,
                    AppUserReference = appUser,
                    BranchReference  = branch,
                    CreatedOn        = userTaskForUser.CreatedOn,
                    CreatedBy        = AppUserHelpers.GetAppUser(db, userTaskForUser.CreatedBy),
                    EntityStatus     = userTaskForUser.EntityStatus
                };

                userTasksForUserView.Add(userTaskForUserView);
            }

            return(userTasksForUserView);
        }
Пример #5
0
        // GET: Task
        public ActionResult Details(Guid?userTaskId)
        {
            if (userTaskId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ApplicationDbContext db = new ApplicationDbContext();

            //Get current user for building the Usertaskview of selected record
            AppUser appUser = AppUserHelpers.GetAppUser(db, User);

            //Get UserTaskView of selected UserTask record
            UserTaskView     userTaskView     = null;
            UserTaskFullView userTaskFullView = new UserTaskFullView()
            {
                UserTaskView = userTaskView
            };

            try  //try helps with issues, if no records for example then we are left with null userTaskView instead of error
            {
                userTaskView = UserTaskViewHelpers.GetUserTaskForUserView(db, appUser.AppUserId, userTaskId.Value);

                //Get the requestor appuser details and branch details
                AppUser createdByAppUser = AppUserHelpers.GetAppUser(userTaskView.CreatedBy.AppUserId);
                Branch  createdByAppUserCurrentBranch = BranchHelpers.GetCurrentBranchForUser(db, userTaskView.CreatedBy.AppUserId);

                //If this is a on-hold user then get the current user role
                BranchUser branchUser = null;

                if (userTaskView.AppUserReference != null)
                {
                    branchUser = BranchUserHelpers.GetBranchUser(db, userTaskView.AppUserReference.AppUserId, userTaskView.AppUserReference.CurrentBranchId);
                }

                //Build the view model
                userTaskFullView = new UserTaskFullView();
                userTaskFullView.UserTaskView = userTaskView;
                if (branchUser != null)
                {
                    userTaskFullView.BranchUserUserRole = branchUser.UserRole;
                }
                userTaskFullView.CreatedByAppUser = createdByAppUser;
                userTaskFullView.CreatedByAppUserCurrentBranch = createdByAppUserCurrentBranch;

                if (userTaskView.AppUserReference != null)
                {
                    ViewBag.EntityStatusUserRole = EnumHelpers.GetDescription((EntityStatusEnum)userTaskFullView.UserTaskView.AppUserReference.EntityStatus);
                }
                else
                {
                    ViewBag.EntityStatusUserRole = "";
                }

                if (userTaskView.BranchReference != null)
                {
                    ViewBag.EntityStatusBranchStatus = EnumHelpers.GetDescription((EntityStatusEnum)userTaskFullView.UserTaskView.BranchReference.EntityStatus);
                }
                else
                {
                    ViewBag.EntityStatusBranchStatus = "";
                }

                ViewBag.EntityStatusCreatedByUserRole         = EnumHelpers.GetDescription((EntityStatusEnum)userTaskFullView.CreatedByAppUser.EntityStatus);
                ViewBag.EntityStatusCreatedByUserBranchStatus = EnumHelpers.GetDescription((EntityStatusEnum)userTaskFullView.CreatedByAppUserCurrentBranch.EntityStatus);

                ViewBag.UserTaskUserRole = EnumHelpers.GetDescription((UserRoleEnum)branchUser.UserRole);
            }
            catch { }

            return(View(userTaskFullView));
        }