public CommandResult Delete(string lightId) { DeleteLightCommand command = new DeleteLightCommand(); command.SetLightId(lightId); return(Execute <DeleteLightCommand, CommandResult>(command)); }
public CommandResult Handle(DeleteLightCommand command) { CommandResult result = new CommandResult(); ObjectId lightId = new ObjectId(); if (!ObjectId.TryParse(command.LightId, out lightId)) { AddNotification(nameof(command.LightId), ENotifications.InvalidFormat); } if (Valid) { Light light = _lightRepository.Get(lightId); if (light == null && _lightRepository.Valid) { AddNotification(nameof(command.LightId), ENotifications.NotFound); } if (Valid) { _lightRepository.Delete(light); if (_lightRepository.Valid) { result = new CommandResult(HttpStatusCode.OK); } } else { result = new CommandResult(HttpStatusCode.BadRequest, Notifications); } } else { result = new CommandResult(HttpStatusCode.BadRequest, Notifications); } return(result); }