public JsonResult Save(string year) { var request = this.ControllerContext.HttpContext.Request; var logo = new MemoryStream(); request.Files[0].InputStream.CopyTo(logo); var image = new MemoryStream(); request.Files[1].InputStream.CopyTo(image); var roomTypes = JsonConvert.DeserializeObject <List <dynamic> >(request.Form["roomtypes"]) .Select <dynamic, string>(x => x["description"]) .ToArray(); var command = new CreateHotel { Year = year, Id = Guid.NewGuid(), Name = request.Form["name"], Website = request.Form["website"], PhoneNumber = request.Form["phonenumber"], RoomTypes = roomTypes, Logo = logo.ToArray(), Image = image.ToArray(), }; Domain.Dispatcher.SendCommand(command); return(Json(command)); }
public IEnumerable Handle(Func <Guid, TournamentAggregate> al, CreateHotel command) { var tournament = CommandQueries.GetTournaments().FirstOrDefault(x => x.Year == command.Year); var agg = al(tournament.Id); yield return(new HotelCreated { Id = tournament.Id, HotelId = command.Id, Name = command.Name, Website = command.Website, PhoneNumber = command.PhoneNumber, RoomTypes = command.RoomTypes, Logo = command.Logo, Image = command.Image }); }