Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 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)));
 }