Example #1
0
        public IEnumerable Handle(Func <Guid, TournamentAggregate> al, CreateCentre command)
        {
            var tournament = CommandQueries.GetTournaments().FirstOrDefault(x => x.Year == command.Year);
            var agg        = al(tournament.Id);

            yield return(new CentreCreated
            {
                Id = tournament.Id,
                CentreId = command.Id,
                Name = command.Name,
                Website = command.Website,
                PhoneNumber = command.PhoneNumber,
                Address = command.Address,
                Image = command.Image
            });
        }
        public JsonResult Save(string year)
        {
            var request = this.ControllerContext.HttpContext.Request;

            var image = new MemoryStream();

            request.Files[0].InputStream.CopyTo(image);

            var command = new CreateCentre
            {
                Year        = year,
                Id          = Guid.NewGuid(),
                Name        = request.Form["name"],
                Website     = request.Form["website"],
                PhoneNumber = request.Form["phonenumber"],
                Address     = request.Form["address"],
                Image       = image.ToArray(),
            };

            Domain.Dispatcher.SendCommand(command);
            return(Json(command));
        }