Skip to content

Commit

Permalink
Add project files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fatih Soyalp committed Dec 2, 2023
1 parent 40c84eb commit e30c06a
Show file tree
Hide file tree
Showing 1,146 changed files with 243,023 additions and 0 deletions.
25 changes: 25 additions & 0 deletions CourseProject.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34316.72
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CourseProject", "CourseProject\CourseProject.csproj", "{ABE7C049-D49A-4AF1-B2A1-5CEFC507C138}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{ABE7C049-D49A-4AF1-B2A1-5CEFC507C138}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ABE7C049-D49A-4AF1-B2A1-5CEFC507C138}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ABE7C049-D49A-4AF1-B2A1-5CEFC507C138}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ABE7C049-D49A-4AF1-B2A1-5CEFC507C138}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D0A9F5B7-7338-4975-B471-3074A946DCBA}
EndGlobalSection
EndGlobal
90 changes: 90 additions & 0 deletions CourseProject/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
using CourseProject.Models.Entity;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;

namespace CourseProject.Controllers
{
[AllowAnonymous]
public class AccountController : Controller
{
private readonly UserManager<IdentityUser> userManager;
private readonly SignInManager<IdentityUser> signInManager;
public AccountController(UserManager<IdentityUser> userManager, SignInManager<IdentityUser> signInManager)
{
this.userManager = userManager;
this.signInManager = signInManager;
}

public UserManager<IdentityUser> UserManager { get; }

public IActionResult Register()
{
return View();
}
[HttpPost]
public async Task<IActionResult> Register(RegisterViewModel registerViewModel)
{
if (ModelState.IsValid)
{
var identityUser = new IdentityUser
{
UserName = registerViewModel.Username,
Email = registerViewModel.Email,
};

var identityResult = await userManager.CreateAsync(identityUser, registerViewModel.Password);

if (identityResult.Succeeded)
{
// assign this user the "User" role
var roleIdentityResult = await userManager.AddToRoleAsync(identityUser, "User");

if (roleIdentityResult.Succeeded)
{
// Show success notification
return RedirectToAction("Login", "Account");
}
}
}
// Show error notification
return View();
}
public IActionResult Login(string ReturnUrl)
{
var model = new LoginViewModel
{
ReturnUrl = ReturnUrl,
};
return View();
}
[HttpPost]
public async Task<IActionResult> Login(LoginViewModel loginViewModel)
{
var signInResult = await signInManager.PasswordSignInAsync(loginViewModel.Username, loginViewModel.Password, false, false);

if (signInResult != null && signInResult.Succeeded)
{
if (!string.IsNullOrWhiteSpace(loginViewModel.ReturnUrl))
{
return RedirectToPage("loginViewModel.ReturnUrl");
}

return RedirectToAction("Index", "DefaultPage");
}

//Show errors
return View();
}

public async Task<IActionResult> Logout()
{
await signInManager.SignOutAsync();
return RedirectToAction("Index", "DefaultPage");
}
public IActionResult AccessDenied()
{
return View();
}
}
}
27 changes: 27 additions & 0 deletions CourseProject/Controllers/ContactDetailsController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using CourseProject.Models.Entity;
using CourseProject.Repositories;
using Microsoft.AspNetCore.Mvc;

namespace CourseProject.Controllers
{
public class ContactDetailsController : Controller
{
private readonly IContactDetailsRepository _contactDetailsRepository;

public ContactDetailsController(IContactDetailsRepository contactDetailsRepository)
{
_contactDetailsRepository = contactDetailsRepository;
}
public async Task<IActionResult> Index()
{
var value = await _contactDetailsRepository.GetAsync(1);
return View(value);
}
[HttpPost]
public async Task<IActionResult> Index(ContactDetail contactDetail)
{
await _contactDetailsRepository.UpdateAsync(contactDetail);
return RedirectToAction("Index");
}
}
}
24 changes: 24 additions & 0 deletions CourseProject/Controllers/ContactPageController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using CourseProject.Repositories;
using CourseProject.ViewComponents;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace CourseProject.Controllers
{
[AllowAnonymous]
public class ContactPageController : Controller
{
private readonly IContactDetailsRepository _contactDetailsRepository;

public ContactPageController(IContactDetailsRepository contactDetailsRepository)
{
_contactDetailsRepository = contactDetailsRepository;
}

public async Task<IActionResult> Index()
{
var values = await _contactDetailsRepository.GetAllAsync();
return View(values);
}
}
}
36 changes: 36 additions & 0 deletions CourseProject/Controllers/DefaultPageController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using CourseProject.Models.Entity;
using CourseProject.Repositories;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace CourseProject.Controllers
{
[AllowAnonymous]
public class DefaultPageController : Controller
{
private readonly IMatchDetailsRepository _matchDetailsRepository;

public DefaultPageController(IMatchDetailsRepository matchDetailsRepository)
{
_matchDetailsRepository = matchDetailsRepository;
}

public IActionResult Index()
{
return View();
}
public async Task<IActionResult> ShowTicket(int id)
{
var ticketPage = await _matchDetailsRepository.GetAsync(id);
ViewBag.MatchDetail = ticketPage;
return View(ticketPage);
}
[HttpPost]
public async Task<IActionResult> BuyTicket(BuyTicket buyTicket)
{
buyTicket.Date = DateTime.Now;
await _matchDetailsRepository.BuyAsync(buyTicket);
return Json(new { success = true, message = "Bilet alımı başarılı!" });
}
}
}
75 changes: 75 additions & 0 deletions CourseProject/Controllers/MatchDetailsController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using CourseProject.Models.Entity;
using CourseProject.Repositories;
using Microsoft.AspNetCore.Mvc;

namespace CourseProject.Controllers
{
public class MatchDetailsController : Controller
{
private readonly IMatchDetailsRepository _matchDetailsRepository;

public MatchDetailsController(IMatchDetailsRepository matchDetailsRepository)
{
_matchDetailsRepository = matchDetailsRepository;
}

public async Task<IActionResult> Index()
{
var values = await _matchDetailsRepository.GetAllAsync();
return View(values);
}
public IActionResult AddMatch()
{
return View();
}
[HttpPost]
public async Task<IActionResult> AddMatch(MatchDetail matchDetail)
{
if(HttpContext.Request.Form.Files.Count != 0)
{
IFormFile file = HttpContext.Request.Form.Files[0];
string filename = Path.GetFileNameWithoutExtension(file.FileName);
string extension = Path.GetExtension(file.FileName);
string imgFilePath = Path.Combine("wwwroot", "matchImage", filename + extension);

using (FileStream stream = new FileStream(imgFilePath, FileMode.Create))
{
file.CopyTo(stream);
}
matchDetail.MatchImage = "/matchImage/" + filename + extension;
}
await _matchDetailsRepository.AddAsync(matchDetail);
return RedirectToAction("Index");
}
public async Task<IActionResult> EditMatch(int id)
{
var existingMatch = await _matchDetailsRepository.GetAsync(id);
return View(existingMatch);
}
[HttpPost]
public async Task<IActionResult> EditMatch(MatchDetail matchDetail)
{
if (HttpContext.Request.Form.Files.Count != 0 && !string.IsNullOrEmpty(HttpContext.Request.Form.Files[0].FileName))
{
IFormFile file = HttpContext.Request.Form.Files[0];
string filename = Path.GetFileNameWithoutExtension(file.FileName);
string extension = Path.GetExtension(file.FileName);
string imgFilePath = Path.Combine("wwwroot", "matchImage", filename + extension);

using (FileStream stream = new FileStream(imgFilePath, FileMode.Create))
{
file.CopyTo(stream);
}
matchDetail.MatchImage = "/matchImage/" + filename + extension;
}
await _matchDetailsRepository.UpdateAsync(matchDetail);
return RedirectToAction("Index");
}
public async Task<IActionResult> DeleteMatch(int id)
{
await _matchDetailsRepository.DeleteAsync(id);
return RedirectToAction("Index");
}

}
}
78 changes: 78 additions & 0 deletions CourseProject/Controllers/SliderController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using CourseProject.Models.Entity;
using CourseProject.Repositories;
using Microsoft.AspNetCore.Mvc;

namespace CourseProject.Controllers
{
public class SliderController : Controller
{
private readonly ISliderItemRepository _sliderItemRepository;

public SliderController(ISliderItemRepository sliderItemRepository)
{
_sliderItemRepository = sliderItemRepository;
}

public async Task<IActionResult> Index()
{
var values = await _sliderItemRepository.GetAllAsync();
return View(values);
}
public IActionResult AddSlider()
{
return View();
}

[HttpPost]
public async Task<IActionResult> AddSlider(SliderItem sliderItem)
{
if (HttpContext.Request.Form.Files.Count != 0)
{
IFormFile file = HttpContext.Request.Form.Files[0];
string filename = Path.GetFileNameWithoutExtension(file.FileName);
string extension = Path.GetExtension(file.FileName);
string imgFilePath = Path.Combine("wwwroot", "sliderImage", filename + extension);

using (FileStream stream = new FileStream(imgFilePath, FileMode.Create))
{
file.CopyTo(stream);
}
sliderItem.Image = "/sliderImage/" + filename + extension;
}
sliderItem.Date = DateTime.Now;
await _sliderItemRepository.AddAsync(sliderItem);
return RedirectToAction("Index");
}
public async Task<IActionResult> EditSlider(int id)
{
var existingSlider = await _sliderItemRepository.GetAsync(id);
return View(existingSlider);
}
[HttpPost]
public async Task<IActionResult> EditSlider(SliderItem sliderItem)
{
if (HttpContext.Request.Form.Files.Count != 0 && !string.IsNullOrEmpty(HttpContext.Request.Form.Files[0].FileName))
{
IFormFile file = HttpContext.Request.Form.Files[0];
string filename = Path.GetFileNameWithoutExtension(file.FileName);
string extension = Path.GetExtension(file.FileName);
string imgFilePath = Path.Combine("wwwroot", "sliderImage", filename + extension);

using (FileStream stream = new FileStream(imgFilePath, FileMode.Create))
{
file.CopyTo(stream);
}
sliderItem.Image = "/sliderImage/" + filename + extension;
}
sliderItem.Date = DateTime.Now;
await _sliderItemRepository.UpdateAsync(sliderItem);
return RedirectToAction("Index");
}
public async Task<IActionResult> DeleteSlider(int id)
{
await _sliderItemRepository.DeleteAsync(id);
return RedirectToAction("Index");
}
}
}

Loading

0 comments on commit e30c06a

Please sign in to comment.