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

            yield return(new SponsorCreated
            {
                Id = tournament.Id,
                SponsorId = command.Id,
                Name = command.Name,
                Website = command.Website,
                Image = command.Image
            });
        }
Exemplo n.º 2
0
        public OperationResult Create(CreateSponsor command)
        {
            var operation = new OperationResult();

            if (_sponsorRepository.Exist(x => x.Name == command.Name))
            {
                return(operation.Failed(ApplicationMessages.DuplicatedRecord));
            }

            var ImageFolderName = Tools.ToFolderName(this.GetType().Name);
            var ImagePath       = $"{ImageFolderName}/{command.Name}";
            var imageFileName   = _fileUploader.Upload(command.Image, ImagePath);

            var sponsor = new Sponsor(command.Name, command.Tel, imageFileName, command.ImageAlt,
                                      command.ImageTitle, command.IsVisible, command.Bio);

            _sponsorRepository.Create(sponsor);
            _sponsorRepository.SaveChanges();
            return(operation.Succedded());
        }
Exemplo n.º 3
0
        public JsonResult Save(string year)
        {
            var request = this.ControllerContext.HttpContext.Request;

            var file    = request.Files[0];
            var content = new MemoryStream();

            file.InputStream.CopyTo(content);

            var id = request.Form["id"];

            var command = new CreateSponsor
            {
                Year    = year,
                Id      = Guid.NewGuid(),
                Name    = request.Form["name"],
                Website = request.Form["website"],
                Image   = content.ToArray(),
            };

            Domain.Dispatcher.SendCommand(command);
            return(Json(command));
        }
Exemplo n.º 4
0
        public JsonResult OnPostCreate(CreateSponsor command)
        {
            var result = _sponsorApplication.Create(command);

            return(new JsonResult(result));
        }