public Task DeleteVm(Vm vm) { if (vm is null) { throw new ArgumentNullException(nameof(vm)); } var userVms = _userVmRepository.GetAll(i => i.Vm.Id.Equals(vm.Id)); foreach (var userVm in userVms) { userVm.Vm = null; _userVmRepository.Update(userVm); } _vmRepository.Delete(vm); return(Task.CompletedTask); }
private Task <bool> IsReserved(Vm vm, DateTime startTime, DateTime endTime) { return(Task.FromResult(_userVmRepository .GetAll(uv => uv.Vm.Id.Equals(vm.Id)) .Any(uv => Overlap(uv.StartTime, startTime, uv.EndTime, endTime).Result))); }