public IActionResult EditClub(Club club) { if (ModelState.IsValid) { repository.AddClub(club); return(RedirectToAction("ClubDetails")); } else { return(View(club)); } }
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 string saveClub(string name, Stadium stadium, City city, User user) { var message = ""; var result = new Organization(); var result2 = new OrgStadium(); if (!String.IsNullOrEmpty(name)) { result.Name = name; result.City = city; result.User = user; result2.Organization = result; result2.Stadium = stadium; _clubRepository.AddClub(result, result2); message = "Podaci su uspjeĆĄno spremljeni"; } else { message = "Ime kluba nije uneseno"; } return(message); }
public IActionResult AddNewClub([FromBody] Club newClub) { if (!TryValidateModel(newClub)) { return(BadRequest(ModelState)); } _clubRepository.AddClub(newClub); return(Created(Request.Path, newClub)); }
public ViewResult AddClub(Club club) { if (ModelState.IsValid) { club.Players = new List <Player>(); repository.AddClub(club); TempData["message"] = $"New club \"{club.Name}\" has been created"; return(View("Clubs", repository.Clubs)); } TempData["warning"] = $"Please complete this form"; return(View()); }
public void ShouldReturnClub() { IClubRepository clubRepository = GetInMemoryClubRepository(); var club1 = new ClubDto { Name = "Name1", UniversityName = "University1" }; var club2 = new ClubDto { Name = "Name2", UniversityName = "University2" }; var addedClub1 = clubRepository.AddClub(club1); var addedClub2 = clubRepository.AddClub(club2); var response = clubRepository.GetClub(addedClub1.Id); Assert.NotEqual(response, addedClub2); var responseJson = JsonConvert.SerializeObject(response); var addedClub1Json = JsonConvert.SerializeObject(addedClub1); Assert.Equal(responseJson, addedClub1Json); }
public async Task <IActionResult> AddClub([FromBody] ClubDto clubDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var userId = User.FindFirst(JwtRegisteredClaimNames.Sub)?.Value; var user = await _userManager.FindByIdAsync(userId); clubDto.CreatedBy = user?.Id; var newClub = _clubRepository.AddClub(clubDto); return(Ok(newClub)); }
public IActionResult Create(Club c) { //FakeClubRepository.AddClub(c); repository.AddClub(c); return(RedirectToAction("Index")); }
public ActionResult AddClub(Club clubs) { clubRepository.AddClub(clubs); ModelState.Clear(); return(RedirectToAction("Club", "Club")); }