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); } }
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); }
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); }
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); } } } }
public void AddAllUnitStateRoles(List <UnitStateRole> roles) { _unitStateRoleRepository.SaveOrUpdateAll(roles); }