public async Task <IActionResult> Create(ClubVM model) { if (ModelState.IsValid) { string uniqueFileName = null; var user = _userManager.GetUserAsync(HttpContext.User); if (model.Photo != null) { string uploadsFolder = Path.Combine(_env.WebRootPath, "ImageClub"); uniqueFileName = Guid.NewGuid().ToString() + "_" + model.Photo.FileName; string filePath = Path.Combine(uploadsFolder, uniqueFileName); await model.Photo.CopyToAsync(new FileStream(filePath, FileMode.Create)); } var club = new Club { Name = model.Name, City = model.City, Address = model.Address, Number = model.Number, User = user.Result, ZdjecieUrl = uniqueFileName }; _RepositoryClub.AddClub(club); return(RedirectToAction(nameof(Index))); } return(View(model)); }
public ActionResult <ClubVM> Post(ClubVM clubVM) { var club = new Club() { Name = clubVM.ClubName }; _context.Clubs.Add(club); _context.SaveChanges(); return(Ok(club)); }
public IActionResult Subscribe(int id) { ClubVM clubvm = new ClubVM(); List <int> clubids = _context.RegattaClubs.Where(e => e.RegattaId == id).Select(e => e.ClubId).ToList(); ViewData["ClubId"] = new SelectList(_context.Clubs.Where(e => !clubids.Contains(e.ClubId)).OrderBy(e => e.Name).ToList(), "ClubId", "Name"); ViewBag.regatta = _context.Regattas.FirstOrDefault(e => e.RegattaId == id); return(View(clubvm)); }
public async Task <Response> GetClub(int id) { var club = await Context.Clubs .Include(i => i.RelationsWith) .Include(i => i.InRelationsWith).ThenInclude(relation => relation.FirstClub) .Include(i => i.Fans) .Include(i => i.Chants) .FirstOrDefaultAsync(i => !i.IsDeleted && i.Id == id); var clubDto = new ClubVM() { Id = club.Id, Name = club.Name, League = club.League, LogoUri = club.LogoUri, City = club.City, Longitude = club.Longitude, Latitude = club.Latitude, Chants = club.Chants.Select(row => new ChantVM() { Id = row.Id, Lyrics = row.Lyrics }).ToList(), ClubRelations = club.InRelationsWith.Select(row => new ClubRelationVM() { ClubId = row.FirstClub.Id, ClubName = row.FirstClub.Name, Relation = row.Relation }).ToList(), Fans = club.Fans.Select(row => new MemberVM() { MemberId = row.Id, Name = row.UserName, }).ToList(), }; return(new SuccessResponse <ClubVM>(clubDto)); }
public IActionResult Details(int?id) { if (id == null) { return(NotFound()); } Club club = clubService.GetClubById(Convert.ToInt32(id)); if (club == null) { return(NotFound()); } var clubDetails = new ClubVM(); clubDetails = _mapper.Map <ClubVM>(club); clubDetails.Vakken = new SelectList(vakService.GetAll(), "Id", "Omschrijving"); return(View(clubDetails)); }
public IActionResult Subscribe(ClubVM clubvm) { var club = _context.Clubs.FirstOrDefault(e => e.ClubId == clubvm.ClubId); club.EMail = clubvm.EMail; Guid g; g = Guid.NewGuid(); var regatta = _context.Regattas.Include(e => e.RegattaClubs).SingleOrDefault(m => m.RegattaId == clubvm.RegattaId); if (!_context.RegattaClubs.Any(e => e.RegattaId == regatta.RegattaId && e.ClubId == club.ClubId)) { _context.RegattaClubs.Add(new RegattaClub { RegattaId = regatta.RegattaId, ClubId = club.ClubId, Guid = g.ToString() }); _context.SaveChanges(); return(RedirectToAction("Thankyou")); } return(RedirectToAction("Subscribe")); }
public IActionResult Koop(int?aboClubId, int?vakId) { ClubVM getClubVM(int?id) { Club clubDetails = clubService.GetClubById(Convert.ToInt32(id)); var clubVM = new ClubVM(); clubVM = _mapper.Map <ClubVM>(clubDetails); clubVM.Vakken = new SelectList(vakService.GetAll(), "Id", "Omschrijving"); return(clubVM); } if (vakId == null || vakId == 0 || aboClubId == 0 || aboClubId == null) { if (aboClubId == null || aboClubId == 0) { return(NotFound()); } else { ModelState.AddModelError("error", "Er moet een vak gekozen worden."); return(View("Details", getClubVM(aboClubId))); } } Club club = clubService.GetClubById(Convert.ToInt32(aboClubId)); Stadion stadion = stadionService.GetStadionById(Convert.ToInt32(club.StadionId)); Vak vak = vakService.GetVakById(Convert.ToInt32(vakId)); StadionVak stadionVak = stadionVakService.GetStadionVakByStadIdAndVakId(Convert.ToInt32(stadion.Id), Convert.ToInt32(vak.Id)); decimal? kostprijs = stadionVak.AbonnementPrijs; //abonementprijs is null mag niet moet nog aangepast worden in database kostprijs = 100; ShoppingCartVM shopping; int atlItems = 0; if (HttpContext.Session.GetObject <ShoppingCartVM>("ShoppingCart") != null) { shopping = HttpContext.Session.GetObject <ShoppingCartVM>("ShoppingCart"); } else { shopping = new ShoppingCartVM(); shopping.ShoppingCart = new List <CartVM>(); } Boolean shoppingcartVol() { foreach (CartVM cart in shopping.ShoppingCart) { atlItems += cart.Aantal; } if (atlItems >= 10) { return(true); } else { return(false); } } Boolean shoppingcartHeeftEenAbo() { Boolean isAbo = false; foreach (CartVM cart in shopping.ShoppingCart) { if (cart.WedstrijdId.Equals(null)) { isAbo = true; } } return(isAbo); } if (shoppingcartVol()) { ModelState.AddModelError("error", "Winkelkar zit vol"); return(View("Details", getClubVM(club.Id))); } else if (shoppingcartHeeftEenAbo()) { ModelState.AddModelError("error", "Je mag geen twee abonementen in je winkelmandje hebben"); return(View("Details", getClubVM(club.Id))); } else { CartVM item = new CartVM { ThuisClubId = club.Id, ThuisClubNaam = club.Naam, StadiumNaam = stadion.Naam, UitCLubNaam = null, VakNaam = vak.Omschrijving, VakId = vak.Id, WedstrijdId = null, WedstrijdDatum = null, Aantal = 1, Prijs = (decimal)kostprijs }; shopping.ShoppingCart.Add(item); HttpContext.Session.SetObject("ShoppingCart", shopping); return(RedirectToAction("Index", "ShoppingCart")); } }