Esempio n. 1
0
        public GridResults LoadPaging(long userId, string search, int pageIndex, out long totalRecords, string sortColumnName = "", string sortOrderBy = "")
        {
            //Get current user
            var user = BlUser.LoadSingle(userId);

            //Query paged data
            var results = LoadPaging(userId, CreateFilter(search), user.PageSize, pageIndex - 1, out totalRecords);

            //Convert results into display model
            var res = (from r in results
                       select new
            {
                r.Id,
                Gender = r.Entity.Gender == null ? "" : BlCode.GetCodeByLanguage(user, BlCode.LoadSingle(userId, "Gender", r.Entity.Gender)),
                Name = BlEntity.FormatFullName(r.Entity),
                Number = r.Entity.IdType == "M" ? r.Entity.IdNum : "",
                r.Entity.FullEnLongName,
                Level = r.Level == null ? "" : BlCode.GetCodeByLanguage(user, BlCode.LoadSingle(userId, "EmployeeLevel", r.Level)),
                Status = r.Status == "A" ? "check colorGreen" : "close colorRed"
            }).ToList();


            //Convert display model into json data
            return(GridVm.FormatResult(res, user.PageSize, pageIndex, totalRecords));
        }
Esempio n. 2
0
        private static DdlVm.DdlOption FormatForQs(int languageId, Employee item, bool returnPin = false)
        {
            var toRet = new DdlVm.DdlOption
            {
                value = returnPin ? item.Entity.Pin.ToUiString() : item.Id.ToUiString(),
                label = BlEntity.FormatFullName(item.Entity)
            };

            return(toRet);
        }
Esempio n. 3
0
        public bool Delete(long userId, Address toDelete)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Delete(toDelete);

                BlLog.Log(userId, Module, "Delete address", "AddressDeleted", new object[] { toDelete.Sequence, toDelete.Entity.Pin, BlEntity.FormatFullName(toDelete.Entity) });
                tran.Complete();
                return(toRet);
            }
        }
Esempio n. 4
0
        public Address Edit(long userId, Address toEdit)
        {
            using (var tran = new TransactionScope())
            {
                if (toEdit.EntryDate == DateTime.MinValue)
                {
                    toEdit.EntryDate = BlCommon.GetServerDateTime();
                }

                var toRet = _repository.Edit(toEdit);

                BlLog.Log(userId, Module, "Edit address", "AddressModified", new object[] { toEdit.Sequence, toEdit.Entity.Pin, BlEntity.FormatFullName(toEdit.Entity) });
                tran.Complete();
                return(toRet);
            }
        }
Esempio n. 5
0
        public Address Create(long userId, Address toAdd)
        {
            using (var tran = new TransactionScope())
            {
                toAdd.EntryDate = BlCommon.GetServerDateTime();
                toAdd.UserId    = userId;
                toAdd.Sequence  = GetPinNextSequence(userId, toAdd.Entity.Pin);
                var toRet = _repository.Create(toAdd);

                BlLog.Log(userId, Module, "Create address", "AddressCreated", new object[] { toAdd.Sequence, toAdd.Entity.Pin, BlEntity.FormatFullName(toAdd.Entity) });
                tran.Complete();
                return(toRet);
            }
        }
Esempio n. 6
0
        public bool Delete(long userId, Employee toDelete)
        {
            using (var tran = new TransactionScope())
            {
                //Check if employee has related user account
                if (BlUser.LoadByPin(userId, toDelete.Entity.Pin) != null)
                {
                    throw new BusinessException("CannotDeleteRelatedUser");
                }

                var toRet = _repository.Delete(toDelete);

                BlLog.Log(userId, Module, "Delete employee", "EmployeeDeleted", new object[] { toDelete.Entity.Pin, BlEntity.FormatFullName(toDelete.Entity) });
                tran.Complete();
                return(toRet);
            }
        }
Esempio n. 7
0
        public Employee Edit(long userId, Employee toEdit)
        {
            using (var tran = new TransactionScope())
            {
                var toRet = _repository.Edit(toEdit);

                BlLog.Log(userId, Module, "Edit employee", "EmployeeModified", new object[] { toEdit.Entity.Pin, BlEntity.FormatFullName(toEdit.Entity) });
                tran.Complete();
                return(toRet);
            }
        }
Esempio n. 8
0
        public Employee Create(long userId, Employee toAdd)
        {
            using (var tran = new TransactionScope())
            {
                toAdd.UserId    = userId;
                toAdd.EntryDate = BlCommon.GetServerDateTime();

                var toRet = _repository.Create(toAdd);

                BlLog.Log(userId, Module, "Create employee", "EmployeeCreated", new object[] { toAdd.Entity.Pin, BlEntity.FormatFullName(toAdd.Entity) });
                tran.Complete();
                return(toRet);
            }
        }