コード例 #1
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);
        }
コード例 #2
0
ファイル: BlBranch.cs プロジェクト: sabounjirony/DeirElAhmar
        public static string GetBranchName(long userId, long branchId)
        {
            var user   = BlUser.LoadSingle(userId);
            var branch = BlBranch.LoadSingle(user.Id, branchId);

            if (user.LanguageId == 1)
            {
                return(branch.Entity.FullEnShortName);
            }
            else
            {
                return(branch.Entity.FullArShortName);
            }
        }
コード例 #3
0
ファイル: BlBranch.cs プロジェクト: sabounjirony/DeirElAhmar
        public static List <DdlVm.DdlOption> GetLov(long userId, bool isMandatory = false)
        {
            var user           = BlUser.LoadSingle(userId);
            var canCrossBranch = BlPermission.CanDo(userId, Module, "CrossBranches");

            var blBranch  = new BlBranch();
            var predicate = PredicateBuilder.True <Branch>();

            predicate = predicate.And(p => p.Status == "A");

            //Retrieve only user branch if cannot cross branch
            if (!canCrossBranch)
            {
                predicate = predicate.And(p => p.Id == user.BranchId);
            }

            var result = blBranch.LoadSearch(userId, predicate).ToList();

            if (!result.Any())
            {
                return(null);
            }

            var results = (from a in result
                           orderby a.Name ascending
                           select new DdlVm.DdlOption
            {
                value = a.Id.ToUiString(),
                label = user.LanguageId == 1 ? a.Entity.FullEnShortName : a.Entity.FullArShortName
            }).ToList();

            //Add empty value if can cross branch
            if (canCrossBranch && !isMandatory)
            {
                results.Insert(0, new DdlVm.DdlOption("...", ""));
            }

            return(results.ToList());
        }