Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 2
0
 public void UpdateEventClub(EventClub model)
 {
     _appDbContext.EventClubs.Update(model);
     _appDbContext.SaveChanges();
 }
Ejemplo n.º 3
0
 public void AddEventClub(EventClub model)
 {
     _appDbContext.EventClubs.Add(model);
     _appDbContext.SaveChanges();
 }