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 }); }
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()); }
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)); }
public JsonResult OnPostCreate(CreateSponsor command) { var result = _sponsorApplication.Create(command); return(new JsonResult(result)); }