public ActionResult Delete(int id) { var handler = new HotelCommandHandler(_repository); var command = new DeleteHotelCommand( id ); handler.Handle(command); if (!handler.Valid) { List <string> errorMessages = new List <string>(); foreach (var erro in handler.Notifications) { errorMessages.Add(erro.Message); } return(BadRequest(new { success = false, errors = errorMessages })); } return(Ok(new { success = true, message = "Exclusão de hotel feito com sucesso" })); }
public ActionResult Put(int id, [FromBody] RegisterHotelVM model) { var handler = new HotelCommandHandler(_repository); var command = new UpdateHotelCommand( id, model.Name, model.Description, model.Rating, model.Street, model.Number, model.ZipCode, model.State, model.City, model.FeatureDescriptions ); handler.Handle(command); if (!handler.Valid) { List <string> errorMessages = new List <string>(); foreach (var erro in handler.Notifications) { errorMessages.Add(erro.Message); } return(BadRequest(new { success = false, errors = errorMessages })); } return(Ok(new { success = true, message = "Atualização do hotel feito com sucesso" })); }