public async Task <IActionResult> AddParty(EventPartyVM model) { if (ModelState.IsValid) { string uniqueFileName = null; var club = _RepositoryEvent.GetClub(model.ClubId).Result; if (model.File != null) { string uploadsFolder = Path.Combine(_env.WebRootPath, "ImageEvent"); uniqueFileName = Guid.NewGuid().ToString() + "_" + model.File.FileName; string filePath = Path.Combine(uploadsFolder, uniqueFileName); await model.File.CopyToAsync(new FileStream(filePath, FileMode.Create)); } EventClub eventClub = new EventClub { EventName = model.Name, DateStart = model.TimeStart, DateEnd = model.TimeEnd, Club = club, Place = club.Address, PhotoUrl = uniqueFileName }; _RepositoryEvent.AddEventClub(eventClub); return(RedirectToAction(nameof(Party))); } return(View()); }
public IActionResult AddParty(int id) { if (id > 0) { var eventParty = new EventPartyVM { ClubId = id }; return(View(eventParty)); } return(View("Not found")); }