Example #1
0
        public object Get(int id, bool success = true, string message = "")
        {
            user user = (user)HttpContext.Current.Session[ECGlobalConstants.CurrentUserMarcker];

            if (user == null || user.id == 0)
            {
                return(null);
            }

            UserModel um = new UserModel(user.id);
            var       rm = new ReportModel(id);

            var m = new
            {
                involved_mediators_user_list    = new List <UserAdv>(),
                mediators_whoHasAccess_toReport = new List <UserAdv>(),
                available_toAssign_mediators    = new List <UserAdv>(),
                currentInfo = um._user,
                message     = message,
                success     = success
            };

            foreach (var item in rm.InvolvedMediatorsUserList().ToList())
            {
                um = new UserModel(item.id);
                m.involved_mediators_user_list.Add(new UserAdv
                {
                    user             = item,
                    task_quantity    = um.CaseTasksQuantity(id),
                    message_quantity = um.CaseMessagesQuantity(id),
                    action_quantity  = um.CaseActionsQuantity(id),
                    location_string  = um._location_string,
                    email            = um._user.email,
                    user_photo       = glb.Photo_Path_String(item.photo_path, 1, 5),
                    owner            = rm.ReportOwners().FirstOrDefault(x => x.user_id == item.id & x.status_id == 2) != null,
                });
            }
            foreach (var item in rm.MediatorsWhoHasAccessToReport().ToList())
            {
                um = new UserModel(item.id);
                m.mediators_whoHasAccess_toReport.Add(new UserAdv
                {
                    user             = item,
                    task_quantity    = um.CaseTasksQuantity(id),
                    message_quantity = um.CaseMessagesQuantity(id),
                    action_quantity  = um.CaseActionsQuantity(id),
                    location_string  = um._location_string,
                    email            = um._user.email,
                    user_photo       = glb.Photo_Path_String(item.photo_path, 1, 5),
                    owner            = rm.ReportOwners().FirstOrDefault(x => x.user_id == item.id & x.status_id == 2) != null,
                });
            }
            foreach (var item in rm.AvailableToAssignMediators().ToList())
            {
                um = new UserModel(item.id);
                m.available_toAssign_mediators.Add(new UserAdv
                {
                    user             = item,
                    task_quantity    = um.CaseTasksQuantity(id),
                    message_quantity = um.CaseMessagesQuantity(id),
                    action_quantity  = um.CaseActionsQuantity(id),
                    location_string  = um._location_string,
                    email            = um._user.email,
                    user_photo       = glb.Photo_Path_String(item.photo_path, 1, 5),
                    owner            = rm.ReportOwners().FirstOrDefault(x => x.user_id == item.id & x.status_id == 2) != null,
                });
            }

            return(ResponseObject2Json(m));
        }