public ICommandResult Handle(DeleteObjectStatusCommand command) { ICommandResult result = new CommandResult(); _loggingService.Log(this.GetType(), ELogType.Neutral, ELogLevel.Debug, new { command.ObjectStatus, command.RequestHost }, "ObjectStatusCommandHandler.Handle(Delete)"); try { if (_objectStatusRepository.CheckExists(command.ObjectStatus)) { if (_objectStatusRepository.Delete(command.ObjectStatus)) { result = new CommandResult(200); } } else if (_objectStatusRepository.Valid) { result = new CommandResult(400, new Notification("Object Status", "Could not be found")); } } catch (Exception e) { _loggingService.Log(this.GetType(), ELogType.Neutral, ELogLevel.Error, new { command.ObjectStatus, command.RequestHost }, e); } return(result); }
public CommandResult Delete(Guid id) { DeleteObjectStatusCommand command = new DeleteObjectStatusCommand() { ObjectStatus = id }; command.setRequestHost(HttpContext.Request.Host.ToString()); _loggingService.Log(this.GetType(), ELogType.Input, ELogLevel.Info, new { ObjectStatus = this.User.Identity.Name, Path = this.Request.Path, Method = this.Request.Method }); CommandResult result = (CommandResult)_objectStatusHandler.Handle(command); _loggingService.Log(this.GetType(), ELogType.Output, ELogLevel.Info, new { ObjectStatus = this.User.Identity.Name, Path = this.Request.Path, Method = this.Request.Method, Code = this.Response.StatusCode }); HttpContext.Response.StatusCode = result.Code; return(result); }