public SetTariffModel GetTariffById(Guid tariffId)
        {
            ICurrentUser _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.settingTariff);
            var          permissionRangeWrite  = PermissionExtention.GetPermissionRange(currentUser.UserMenuPermission.Write);
            var          permissionRangeDelete = PermissionExtention.GetPermissionRange(currentUser.UserMenuPermission.Delete);


            var tariff = DataContext.Get(x => x.Id == tariffId).FirstOrDefault();
            var data   = mapper.Map <SetTariffModel>(tariff);

            BaseUpdateModel baseModel = new BaseUpdateModel
            {
                UserCreated  = data.UserCreated,
                CompanyId    = data.CompanyId,
                DepartmentId = data.DepartmentId,
                OfficeId     = data.OfficeId,
                GroupId      = data.GroupId
            };

            data.Permission = new PermissionAllowBase
            {
                AllowUpdate = PermissionExtention.GetPermissionDetail(permissionRangeWrite, baseModel, currentUser),
                AllowDelete = PermissionExtention.GetPermissionDetail(permissionRangeDelete, baseModel, currentUser),
            };

            data.UserCreatedName   = userRepository.Get(x => x.Id == data.UserCreated).FirstOrDefault()?.Username;
            data.UserModifieddName = userRepository.Get(x => x.Id == data.UserModified).FirstOrDefault()?.Username;

            return(data);
        }
示例#2
0
        public CatChargeAddOrUpdateModel GetChargeById(Guid id)
        {
            CatChargeAddOrUpdateModel returnCharge = new CatChargeAddOrUpdateModel();
            var charge            = DataContext.Get(x => x.Id == id).FirstOrDefault();
            var listChargeDefault = chargeDefaultRepository.Get(x => x.ChargeId == id).ToList();

            returnCharge.Charge = charge;

            // Update permission
            ICurrentUser _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.catCharge);
            var          permissionRangeWrite = PermissionExtention.GetPermissionRange(currentUser.UserMenuPermission.Write);

            BaseUpdateModel baseModel = new BaseUpdateModel
            {
                UserCreated  = returnCharge.Charge.UserCreated,
                CompanyId    = returnCharge.Charge.CompanyId,
                DepartmentId = returnCharge.Charge.DepartmentId,
                OfficeId     = returnCharge.Charge.OfficeId,
                GroupId      = returnCharge.Charge.GroupId
            };

            returnCharge.Permission = new PermissionAllowBase
            {
                AllowUpdate = PermissionExtention.GetPermissionDetail(permissionRangeWrite, baseModel, currentUser),
            };

            returnCharge.ListChargeDefaultAccount = listChargeDefault;

            return(returnCharge);
        }
        public CatPlaceModel GetDetail(Guid id)
        {
            ICurrentUser _user = null;
            CatPlace     data  = DataContext.First(x => x.Id == id);

            if (data == null)
            {
                return(null);
            }

            CatPlaceModel result = mapper.Map <CatPlaceModel>(data);

            if (data.PlaceTypeId == CatPlaceTypeEnum.Warehouse.ToString())
            {
                _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.catWarehouse);
            }
            if (data.PlaceTypeId == CatPlaceTypeEnum.Port.ToString())
            {
                _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.catPortindex);
            }
            if (data.PlaceTypeId == CatPlaceTypeEnum.Province.ToString() ||
                data.PlaceTypeId == CatPlaceTypeEnum.District.ToString() ||
                data.PlaceTypeId == CatPlaceTypeEnum.Ward.ToString())
            {
                _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.catLocation);
            }

            var permissionRangeWrite = PermissionExtention.GetPermissionRange(currentUser.UserMenuPermission.Write);

            BaseUpdateModel baseModel = new BaseUpdateModel
            {
                UserCreated  = result.UserCreated,
                CompanyId    = result.CompanyId,
                DepartmentId = result.DepartmentId,
                OfficeId     = result.OfficeId,
                GroupId      = result.GroupId
            };

            result.Permission = new PermissionAllowBase
            {
                AllowUpdate = PermissionExtention.GetPermissionDetail(permissionRangeWrite, baseModel, currentUser),
            };

            return(result);
        }
示例#4
0
        public SetEcusConnectionModel GetConnectionDetails(int id)
        {
            ICurrentUser _user = PermissionExtention.GetUserMenuPermission(currentUser, Menu.settingEcusConnection);
            var          permissionRangeWrite = PermissionExtention.GetPermissionRange(currentUser.UserMenuPermission.Write);

            var data = Get(x => x.Id == id);

            if (data == null)
            {
                return(null);
            }

            var result = data.FirstOrDefault();

            var users = userRepository.Get();

            result.Username         = users.FirstOrDefault(x => x.Id == result.UserId)?.Username;
            result.UserCreatedName  = users.FirstOrDefault(x => x.Id == result.UserCreated)?.Username;
            result.UserModifiedName = users.FirstOrDefault(x => x.Id == result.UserModified)?.Username;

            BaseUpdateModel baseModel = new BaseUpdateModel
            {
                UserCreated  = result.UserCreated,
                CompanyId    = result.CompanyId,
                DepartmentId = result.DepartmentId,
                OfficeId     = result.OfficeId,
                GroupId      = result.GroupId
            };

            result.Permission = new PermissionAllowBase
            {
                AllowUpdate = PermissionExtention.GetPermissionDetail(permissionRangeWrite, baseModel, currentUser),
            };

            return(result);
        }