Example #1
0
        public PermissionVm Init(long userId, long?id)
        {
            var toRet = new PermissionVm
            {
                Statuses   = BlCode.LoadTable(userId, "PermissionStatus"),
                ActionMode = Enumerations.ActionMode.Add,
                Permission = new Permission {
                    Status = "A", Module = new Module()
                }
            };

            if (id != null)
            {
                var permission = LoadSingle(userId, Convert.ToInt64(id));
                toRet.Permission = permission;
                //Create roles tree
                var blRole = new BlRole();
                var roles  = blRole.LoadForPermission(userId, permission.Module.Id, permission.Code);

                toRet.RolesTree = new JavaScriptSerializer().Serialize((from r in roles
                                                                        select new TreeItemVm
                {
                    id = r.Id.ToUiString(),
                    parent = r.ParentRole == null ? "#" : r.ParentRole.Id.ToString(),
                    text = r.Code ?? "",
                    icon = "fa fa-users colorMain",
                    state = "{\"checked\": \"" + (r.IsActive ? "true" : "false") + "\"}",
                    li_attr = "{\"class\" : \"form-control-label\"}"
                }));
                toRet.Signature  = BlCommon.GetSignature(toRet.Permission.UserId, toRet.Permission.EntryDate);
                toRet.ActionMode = Enumerations.ActionMode.Edit;
            }

            return(toRet);
        }
Example #2
0
        public EmployeeVm Init(long userId, long?id)
        {
            var user = BlUser.LoadSingle(userId);

            var toRet = new EmployeeVm
            {
                Branches   = BlBranch.GetLov(userId, true).ToDictionary(i => i.value, i => i.label),
                Titles     = BlCode.LoadTable(userId, "Title"),
                Genders    = BlCode.LoadTable(userId, "Gender"),
                IdTypes    = BlCode.LoadTable(userId, "IdType"),
                Maritals   = BlCode.LoadTable(userId, "Marital"),
                Statuses   = BlCode.LoadTable(userId, "Status"),
                Levels     = BlCode.LoadTable(userId, "EmployeeLevel"),
                ActionMode = Enumerations.ActionMode.Add,
                Employee   = new Employee {
                    Status = "A", Entity = new Entity {
                        BranchId = user.BranchId, Nationality = 422, Status = "A"
                    }, Level = "0"
                }
            };

            if (id != null)
            {
                var obj = LoadSingle(userId, Convert.ToInt64(id));
                toRet.Employee   = obj;
                toRet.ActionMode = Enumerations.ActionMode.Edit;
                toRet.Signature  = BlCommon.GetSignature(toRet.Employee.UserId, toRet.Employee.EntryDate);
            }

            return(toRet);
        }
Example #3
0
        public UserVm Init(long userId, long?id)
        {
            var callingUser = LoadSingle(userId);

            var toRet = new UserVm
            {
                Branches   = BlBranch.GetLov(userId, true).ToDictionary(i => i.value, i => i.label),
                Languages  = BlCode.LoadTable(userId, "Language", callingUser.LanguageId == (int)Enumerations.Languages.English ? "Value1" : "Value2"),
                PageSizes  = BlCode.LoadTable(userId, "PageSizes", callingUser.LanguageId == (int)Enumerations.Languages.English ? "Value1" : "Value2"),
                ActionMode = Enumerations.ActionMode.Add,
                User       = new User {
                    LanguageId = 1, PageSize = 10
                }
            };

            if (id != null)
            {
                var user = LoadSingle((long)id);
                user.Pin    = user.Entity == null ? user.Pin : user.Entity.Pin;
                user.Entity = null;
                //user.Branch = null;
                toRet.User      = user;
                toRet.Signature = BlCommon.GetSignature(toRet.User.EnteringUserId, toRet.User.EntryDate);
                //Get all roles and check user assigned ones
                var blRole = new BlRole();
                var roles  = blRole.LoadAll(userId).ToList();
                if (user.Roles != null)
                {
                    foreach (var role in user.Roles)
                    {
                        if (roles.Where(r => r.Id == role.Id).Any())
                        {
                            roles.Where(r => r.Id == role.Id).SingleOrDefault().IsActive = true;
                        }
                    }
                }
                toRet.UserRoles = new JavaScriptSerializer().Serialize((from r in roles
                                                                        select new TreeItemVm
                {
                    id = r.Id.ToUiString(),
                    parent = r.ParentRole == null ? "#" : r.ParentRole.Id.ToUiString(),
                    text = r.Code ?? "",
                    icon = "fa fa-users colorMain",
                    state = "{\"checked\": \"" + (r.IsActive ? "true" : "false") + "\"}",
                    li_attr = "{\"class\" : \"form-control-label\"}"
                }));
                //user.Roles = null;
                toRet.ActionMode = Enumerations.ActionMode.Edit;
            }

            return(toRet);
        }
Example #4
0
        public UserVm ProfileInit(long userId)
        {
            var user  = LoadSingle(userId, true);
            var toRet = new UserVm
            {
                User       = user,
                Languages  = BlCode.LoadTable(userId, "Language", user.LanguageId == (int)Enumerations.Languages.English ? "Value1" : "Value2"),
                PageSizes  = BlCode.LoadTable(userId, "PageSizes", user.LanguageId == (int)Enumerations.Languages.English ? "Value1" : "Value2"),
                Signature  = BlCommon.GetSignature(user.EnteringUserId, user.EntryDate),
                ActionMode = Enumerations.ActionMode.Edit
            };

            return(toRet);
        }
Example #5
0
        public XtraVm Init(long userId, string Object, long id, string property)
        {
            long branchId = 0;
            var  toRet    = new XtraVm
            {
                ActionMode = Enumerations.ActionMode.Add,
                Properties = BlCode.LoadTable(userId, "ProductOpenProperty_" + branchId, "", branchId.ToString()),
                Xtra       = new Xtra {
                    Object = Object, Id = id
                }
            };

            if (property != "null")
            {
                var obj = LoadSingle(userId, Object, id, property);
                toRet.Xtra       = obj;
                toRet.ActionMode = Enumerations.ActionMode.Edit;
            }

            return(toRet);
        }
Example #6
0
        public MenuVm Init(long userId, long?id)
        {
            var toRet = new MenuVm
            {
                Branches = BlBranch.GetLov(userId).ToDictionary(i => i.value, i => i.label),
                Statuses = BlCode.LoadTable(userId, "Status"),
                Menu     = new Menu {
                    Status = true
                },
                ActionMode = Enumerations.ActionMode.Add
            };

            if (id != 0)
            {
                var menu = LoadSingle(userId, Convert.ToInt64(id));
                toRet.Menu       = menu;
                toRet.ActionMode = Enumerations.ActionMode.Edit;
            }

            return(toRet);
        }
Example #7
0
        public DescriptionVm Init(long userId, long?id)
        {
            var toRet = new DescriptionVm
            {
                Languages          = BlCode.LoadTable(userId, "Language"),
                DescriptionParents = BlCode.LoadTable(userId, "DescriptionParent"),
                ActionMode         = Enumerations.ActionMode.Add,
                Description        = new Description {
                    LanguageId = 0, Parent = ""
                }
            };

            if (id != null)
            {
                var description = LoadSingle(userId, (long)id);
                toRet.Description = description;
                toRet.ActionMode  = Enumerations.ActionMode.Edit;
            }

            return(toRet);
        }
Example #8
0
        public ModuleVm Init(long userId, string id)
        {
            var toRet = new ModuleVm
            {
                Branches = BlBranch.GetLov(userId).ToDictionary(i => i.value, i => i.label),
                Statuses = BlCode.LoadTable(userId, "Status"),
                Module   = new Module {
                    Status = "A"
                },
                ActionMode = Enumerations.ActionMode.Add
            };

            if (id != "null")
            {
                var module = LoadSingle(userId, id);
                toRet.Module = module;
                //module.User.Roles = null;
                //module.Author.Roles = null;
                toRet.Signature  = BlCommon.GetSignature(toRet.Module.UserId, toRet.Module.EntryDate);
                toRet.ActionMode = Enumerations.ActionMode.Edit;
            }

            return(toRet);
        }