示例#1
0
        public void ClearGroupForLogs(int departmentGroupId)
        {
            var logs = _logsRepository.GetAll().Where(x => x.StationGroupId == departmentGroupId).ToList();

            if (logs != null && logs.Any())
            {
                foreach (var log in logs)
                {
                    log.StationGroupId = null;
                    log.StationGroup   = null;
                }

                _logsRepository.SaveOrUpdateAll(logs);
            }
        }
示例#2
0
        public void ClearGroupForUnits(int departmentGroupId)
        {
            if (departmentGroupId <= 0)
            {
                throw new ArgumentException("DepartmentGroupId cannot be null", "departmentGroupId");
            }

            var units = (from r in _unitsRepository.GetAll()
                         where r.StationGroupId == departmentGroupId
                         select r);

            foreach (var unit in units)
            {
                unit.StationGroupId = null;
                unit.StationGroup   = null;
            }

            _unitsRepository.SaveOrUpdateAll(units);
        }
示例#3
0
        public List <UnitRole> SetRolesForUnit(int unitId, List <UnitRole> roles)
        {
            if (unitId <= 0)
            {
                throw new ArgumentException("UnitId cannot be null", "unitId");
            }

            if (roles == null || roles.Count == 0)
            {
                throw new ArgumentException("Unit Roles cannot be null or empty", "roles");
            }

            ClearRolesForUnit(unitId);

            foreach (var role in roles)
            {
                role.UnitId = unitId;
            }
            _unitRolesRepository.SaveOrUpdateAll(roles);

            return(roles);
        }
示例#4
0
        public void ProposeShiftDaysForTrade(int shiftTradeId, string userId, string reason, List <int> signups)
        {
            var trade = GetShiftTradeById(shiftTradeId);

            var userTradeRequest = trade.Users.FirstOrDefault(x => x.UserId == userId);

            if (userTradeRequest != null)
            {
                userTradeRequest.Reason  = reason;
                userTradeRequest.Offered = true;

                _shiftSignupTradeUserRepository.SaveOrUpdate(userTradeRequest);

                if (signups != null && signups.Any())
                {
                    var shiftSignups = new List <ShiftSignupTradeUserShift>();
                    foreach (var i in signups)
                    {
                        var signup = GetShiftSignupById(i);

                        if (signup != null)
                        {
                            var shift = new ShiftSignupTradeUserShift();
                            shift.ShiftSignupTradeUserId = userTradeRequest.ShiftSignupTradeUserId;
                            shift.ShiftSignupId          = signup.ShiftSignupId;

                            shiftSignups.Add(shift);
                        }
                    }

                    if (shiftSignups.Any())
                    {
                        _shiftSignupTradeUserShiftsRepository.SaveOrUpdateAll(shiftSignups);
                    }
                }
            }
        }
示例#5
0
 public void AddAllUnitStateRoles(List <UnitStateRole> roles)
 {
     _unitStateRoleRepository.SaveOrUpdateAll(roles);
 }