public CommandResult Delete(string buzzerId) { DeleteBuzzerCommand command = new DeleteBuzzerCommand(); command.SetBuzzerId(buzzerId); return(Execute <DeleteBuzzerCommand, CommandResult>(command)); }
public CommandResult Handle(DeleteBuzzerCommand command) { CommandResult result = new CommandResult(); ObjectId buzzerId = new ObjectId(); if (!ObjectId.TryParse(command.BuzzerId, out buzzerId)) { AddNotification(nameof(command.BuzzerId), ENotifications.InvalidFormat); } if (Valid) { Buzzer buzzer = _buzzerRepository.Get(buzzerId); if (buzzer == null && _buzzerRepository.Valid) { AddNotification(nameof(command.BuzzerId), ENotifications.NotFound); } if (Valid) { _buzzerRepository.Delete(buzzer); if (_buzzerRepository.Valid) { result = new CommandResult(HttpStatusCode.OK); } } else { result = new CommandResult(HttpStatusCode.BadRequest, Notifications); } } else { result = new CommandResult(HttpStatusCode.BadRequest, Notifications); } return(result); }