public int CreateCompanyBuildingObject(int companyId, int buildingObjectId, string host)
        {
            int result = 0;

            using (IUnitOfWork work = UnitOfWork.Begin())
            {
                CompanyBuildingObject cbo = DomainObjectFactory.CreateCompanyBuildingObject();

                cbo.CompanyId        = companyId;
                cbo.BuildingObjectId = buildingObjectId;
                cbo.ValidFrom        = DateTime.Now;
                cbo.ValidTo          = DateTime.Now.AddYears(2);
                cbo.IsDeleted        = false;

                _companyBuildingObjectRepository.Add(cbo);

                work.Commit();

                result = cbo.Id;

                cbo = _companyBuildingObjectRepository.FindById(result);

                var message = new StringBuilder();
                message.Append(string.Format("Building objects for Company '{0}' changed. ", cbo.Company.Name));
                message.Append(string.Format("Room '{0}' in '{1}' added. ", cbo.BuildingObject.Description,
                                             cbo.BuildingObject.Building.Name));

                _logService.CreateLog(CurrentUser.Get().Id, "web", flag, host, CurrentUser.Get().CompanyId, message.ToString());
            }

            return(result);
        }
Пример #2
0
        private List <User> UsersByFloor(int floorId, int companyId)
        {
            var bo = _companyBuildingObjectRepository.FindById(floorId);

            var         user_pririty = _userRepository.FindById(CurrentUser.Get().Id).RolePriority();
            List <User> users        = _userRepository.FindAll(x => !x.IsDeleted && user_pririty <= x.RolePriority()).ToList();

            users = users.Where(x => !x.IsDeleted && x.Active && x.UserBuildings != null && x.UserBuildings.Any(ubo => !ubo.IsDeleted && ubo.BuildingObjectId == bo.BuildingObjectId)).
                    ToList();

            return(users);
        }