예제 #1
0
        protected override void Handle(DeleteSnapshotRequest request)
        {
            if (string.IsNullOrEmpty(request.Location.PotName))
            {
                throw new Exception("Pot name was not provided.");
            }

            if (request.Location.SnapshotIndex.HasValue)
            {
                snapshotRepository.DeleteByIndex(request.Location.PotName, request.Location.SnapshotIndex.Value);
            }
            else if (request.Location.SnapshotDate.HasValue)
            {
                DateTime searchedDate = request.Location.SnapshotDate.Value;

                bool foundEndDeleted = snapshotRepository.DeleteByExactDateTime(request.Location.PotName, searchedDate);

                if (foundEndDeleted)
                {
                    return;
                }

                if (searchedDate.TimeOfDay == TimeSpan.Zero)
                {
                    snapshotRepository.DeleteSingleByDate(request.Location.PotName, searchedDate);
                }
            }
            else
            {
                snapshotRepository.DeleteLast(request.Location.PotName);
            }
        }