Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge pull request #249 from DiyorMarket/master #253

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
ac9c546
Merge pull request #249 from DiyorMarket/master
Mirazyzz Feb 2, 2025
66e830b
created oil-mark-mappings and used in controller
Ramadan1011 Feb 4, 2025
202e569
updated create.cshtml
Ramadan1011 Feb 4, 2025
11ebd3a
Update Delete.cshtml
Ramadan1011 Feb 4, 2025
451773e
Update Edit.cshtml
Ramadan1011 Feb 4, 2025
116dc06
Update Index.cshtml
Ramadan1011 Feb 4, 2025
5f41640
Create oil-mark.js
Ramadan1011 Feb 4, 2025
838da14
checkPoints grid
Boburm1rzo Feb 9, 2025
625928d
checkPoint popUp
Boburm1rzo Feb 9, 2025
533c0e6
sidebar logo
Boburm1rzo Feb 9, 2025
9557bf1
update getpositions method
Ramadan1011 Feb 10, 2025
cb56cf6
changed id for email because of match with phonenumber id
Ramadan1011 Feb 10, 2025
2406c7c
select tag is enable or disable by employee position
Ramadan1011 Feb 10, 2025
9f4675e
update datasource
Ramadan1011 Feb 10, 2025
1945b30
update employee.css
Ramadan1011 Feb 10, 2025
078b944
Update CheckPointController.cs
Boburm1rzo Feb 10, 2025
63051ed
Rename oil-mark.js to oilMark.js
Ramadan1011 Feb 11, 2025
39b4a15
Update Index.cshtml
Ramadan1011 Feb 11, 2025
5e07819
update Employee controller
Ramadan1011 Feb 11, 2025
9844f61
popup updated
Boburm1rzo Feb 13, 2025
410f6dd
Merge pull request #256 from DiyorMarket/CheckPoint-Details-PopUp
Boburm1rzo Feb 13, 2025
ed9d221
Merge pull request #257 from DiyorMarket/temp
Boburm1rzo Feb 13, 2025
7910b65
remove unUsed files
Boburm1rzo Feb 15, 2025
d42954e
Merge pull request #258 from DiyorMarket/remove-unused-files
Boburm1rzo Feb 20, 2025
153e80f
Merge branch 'integration' into oil-mark
Ramadan1011 Feb 27, 2025
744eb16
Merge pull request #255 from DiyorMarket/oil-mark
Ramadan1011 Feb 27, 2025
e42559f
SideBar changes
Boburm1rzo Mar 1, 2025
ddcec05
current user service getUserId
Boburm1rzo Mar 1, 2025
32d2bff
views
Boburm1rzo Mar 1, 2025
7296ef5
create manager review
Boburm1rzo Mar 1, 2025
8c4665e
ViewModel and request
Boburm1rzo Mar 1, 2025
b2a15f9
Merge branch 'integration' into save_button
Boburm1rzo Mar 2, 2025
447dc9f
add layout correctly
Ramadan1011 Mar 2, 2025
d8255be
add selected item to oil mark select list
Ramadan1011 Mar 2, 2025
a632979
update mappings
Ramadan1011 Mar 2, 2025
3578eaf
add data annotations to request
Ramadan1011 Mar 2, 2025
182b6f6
add oil mark name and update views
Ramadan1011 Mar 2, 2025
8b9abcf
updates
Boburm1rzo Mar 2, 2025
e895250
rename GetOilMarkAsync
Ramadan1011 Mar 4, 2025
ca5558c
Merge pull request #260 from DiyorMarket/temp
Boburm1rzo Mar 4, 2025
335ceeb
Merge pull request #259 from DiyorMarket/save_button
Boburm1rzo Mar 4, 2025
bc09fe3
code cleanup
Boburm1rzo Mar 10, 2025
720ffba
remove status filter from debts page
Boburm1rzo Mar 10, 2025
9140482
remove layouts folder
Boburm1rzo Mar 10, 2025
c02756a
Merge pull request #264 from DiyorMarket/fix-debts-page-disadvantages
Boburm1rzo Mar 12, 2025
dcff902
Update AuthorizationHandler.cs
Ramadan1011 Mar 13, 2025
19a9720
Merge pull request #266 from DiyorMarket/fix-login
Ramadan1011 Mar 14, 2025
c35dbec
update data annotations
Ramadan1011 Mar 15, 2025
a19c12c
change type to number
Ramadan1011 Mar 15, 2025
1ab3a6d
removed wrong url
Ramadan1011 Mar 15, 2025
1ae10bc
Merge pull request #267 from DiyorMarket/temp
Ramadan1011 Mar 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions CheckDrive.Web/CheckDrive.Web/Controllers/CarsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public async Task<IActionResult> DetailsForMechanicHandover(int id)

public async Task<IActionResult> Create()
{
var oilMarks = await GetOilMarkAsync();
var oilMarks = await GetOilMarksAsync();
ViewBag.OilMarks = oilMarks;

return View();
Expand All @@ -58,7 +58,7 @@ public async Task<IActionResult> Create([FromForm] CreateCarRequest request)
{
if (ModelState.IsValid)
{
var newCar = await carStore.CreateAsync(request);
await carStore.CreateAsync(request);
return RedirectToAction(nameof(Index));
}
return BadRequest(ModelState);
Expand All @@ -67,7 +67,7 @@ public async Task<IActionResult> Create([FromForm] CreateCarRequest request)
public async Task<IActionResult> Edit(int id)
{
var car = await carStore.GetByIdAsync(id);
var oilMarks = await GetOilMarkAsync();
var oilMarks = await GetOilMarksAsync(car.OilMarkId);

ViewBag.OilMarks = oilMarks;
var carRequest = car.ToUpdateViewModel();
Expand Down Expand Up @@ -108,16 +108,17 @@ public async Task<IActionResult> DeleteConfirmed(int id)
return RedirectToAction(nameof(Index));
}

private async Task<List<SelectListItem>> GetOilMarkAsync()
private async Task<List<SelectListItem>> GetOilMarksAsync(int? oilMarkId = default)
{
var oilMarks = await oilMarkStore.GetAsync();

return oilMarks
.Select(e => new SelectListItem()
{
Value = e.Id.ToString(),
Text = e.Name.ToString()
Text = e.Name.ToString(),
Selected = e.Id == oilMarkId
})
.ToList();
}
}
}
40 changes: 30 additions & 10 deletions CheckDrive.Web/CheckDrive.Web/Controllers/CheckPointController.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
using CheckDrive.Web.Stores.CheckPoint;
using CheckDrive.Web.Mappings;
using CheckDrive.Web.Services.CurrentUserService;
using CheckDrive.Web.Stores.CheckPoint;
using CheckDrive.Web.Stores.ManagerReview;
using CheckDrive.Web.ViewModels.CheckPoint;
using Microsoft.AspNetCore.Mvc;

namespace CheckDrive.Web.Controllers
namespace CheckDrive.Web.Controllers;

public class CheckPointController(
ICheckPointStore checkPointStore,
IManagerReviewStore managerReviewStore,
ICurrentUserService currentUserService) : Controller
{
public class CheckPointController : Controller
public async Task<ActionResult> Details(int id)
{
var checkPoint = await checkPointStore.GetByIdAsync(id);

return View(checkPoint);
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Create(CheckPointViewModel model)
{
private readonly ICheckPointStore _checkPointStore;
public CheckPointController(ICheckPointStore checkPointStore)
try
{
_checkPointStore = checkPointStore ?? throw new ArgumentNullException(nameof(checkPointStore));
var createManagerReviewRequest = model.ToCreateManagerReviewRequest();
createManagerReviewRequest.ReviewerId = currentUserService.GetUserId();

var createdReview = await managerReviewStore.CreateAsync(createManagerReviewRequest);

return RedirectToAction("Index", "Home");
}
public async Task<ActionResult> Index(int id)
catch
{
var checkPoint = await _checkPointStore.GetCheckPointByIdAsync(id);

return View(checkPoint);
return View(model);
}
}
}
27 changes: 11 additions & 16 deletions CheckDrive.Web/CheckDrive.Web/Controllers/DebtsController.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
using System.ComponentModel.DataAnnotations;
using System.Reflection;
using CheckDrive.Web.Mappings;
using CheckDrive.Web.Mappings;
using CheckDrive.Web.Models.Enums;
using CheckDrive.Web.Requests.Debt;
using CheckDrive.Web.Stores.Debts;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using System.ComponentModel.DataAnnotations;
using System.Reflection;

namespace CheckDrive.Web.Controllers;

public class DebtsController : Controller
public class DebtsController(IDebtsStore debtStore) : Controller
{
private readonly IDebtsStore _debtStore;
public DebtsController(IDebtsStore debtStore)
{
_debtStore = debtStore ?? throw new ArgumentNullException(nameof(debtStore));
}
public async Task<ActionResult> Index()
{
var debts = await _debtStore.GetAsync();
var debts = await debtStore.GetAsync();

ViewBag.SelectedStatus = GetDebtStatuses();

Expand All @@ -28,19 +23,19 @@ public async Task<ActionResult> Index()
[HttpGet]
public async Task<ActionResult> Edit(int id)
{
var debt = await _debtStore.GetByIdAsync(id);
var debt = await debtStore.GetByIdAsync(id);

var updateRequest = debt.ToUpdateViewModel();

return View(updateRequest);
}

[HttpPost]
public async Task<ActionResult> Edit(UpdateDebtRequest request)
{
{
request.Status = DebtStatus.Paid;

await _debtStore.UpdateAsync(request);
await debtStore.UpdateAsync(request);

return RedirectToAction(nameof(Index));
}
Expand All @@ -53,11 +48,11 @@ private static List<SelectListItem> GetDebtStatuses()
.Where(e => excludedStatuses.Contains(e))
.Select(e => new SelectListItem()
{
Value = e.ToString(),
Value = ((int)e).ToString(),
Text = e.GetType().GetField(e.ToString())?.GetCustomAttribute<DisplayAttribute>()?.Name ?? e.ToString()
})
.ToList();

return statuses;
}
}
14 changes: 8 additions & 6 deletions CheckDrive.Web/CheckDrive.Web/Controllers/EmployeesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace CheckDrive.Web.Controllers;

public class EmployeesController(IEmployeeStore employeeStore, ICarStore carStore) : Controller
{
private static readonly EmployeePosition[] excludedPositions = [EmployeePosition.Custom];

public async Task<ActionResult> Index()
{
var employees = await employeeStore.GetAsync();
Expand Down Expand Up @@ -42,7 +44,7 @@ public async Task<ActionResult> Create(CreateEmployeeRequest request)
try
{
var createdEmployee = await employeeStore.CreateAsync(request);

return RedirectToAction(nameof(Index));
}
catch
Expand All @@ -54,7 +56,7 @@ public async Task<ActionResult> Create(CreateEmployeeRequest request)
public async Task<ActionResult> Edit(int id)
{
var employee = await employeeStore.GetByIdAsync(id);
ViewBag.Positions = GetPositions();
ViewBag.Positions = GetPositions(employee.Position);
ViewBag.Cars = await GetCarsAsync();

var updateRequest = employee.ToUpdateViewModel();
Expand Down Expand Up @@ -99,16 +101,16 @@ public async Task<ActionResult> Delete(int id, IFormCollection _)
}
}

private static List<SelectListItem> GetPositions()
private static List<SelectListItem> GetPositions(EmployeePosition? selectedPosition = EmployeePosition.Driver)
{
var excludedPositions = new[] { EmployeePosition.Manager, EmployeePosition.Custom };
var positions = Enum.GetValues(typeof(EmployeePosition))
.Cast<EmployeePosition>()
.Where(e => !excludedPositions.Contains(e))
.Select(e => new SelectListItem()
{
Value = e.ToString(),
Text = e.GetType().GetField(e.ToString())?.GetCustomAttribute<DisplayAttribute>()?.Name ?? e.ToString()
Text = e.GetType().GetField(e.ToString())?.GetCustomAttribute<DisplayAttribute>()?.Name ?? e.ToString(),
Selected = e == selectedPosition
})
.ToList();

Expand All @@ -123,7 +125,7 @@ private async Task<List<SelectListItem>> GetCarsAsync()
.Select(e => new SelectListItem()
{
Value = e.Id.ToString(),
Text = e.ToString()
Text = $"{e.Model} ({e.Number})"
})
.ToList();
}
Expand Down
30 changes: 6 additions & 24 deletions CheckDrive.Web/CheckDrive.Web/Controllers/ErrorController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ namespace CheckDrive.Web.Controllers;
[Route("Error")]
public class ErrorController : Controller
{
public IActionResult Index()
{
return View();
}
public IActionResult Index() => View();

[Route("{statusCode:int}")]
public IActionResult ErrorPage(int statusCode)
Expand All @@ -23,28 +20,13 @@ public IActionResult ErrorPage(int statusCode)
};
}

public IActionResult Unauthorized()
{
return View();
}
public IActionResult Unauthorized() => View();

public IActionResult Forbidden()
{
return View();
}
public IActionResult Forbidden() => View();

public IActionResult NotFound()
{
return View();
}
public IActionResult NotFound() => View();

public IActionResult InternalServerError()
{
return View();
}
public IActionResult InternalServerError() => View();

public IActionResult Error409()
{
return View();
}
public IActionResult Error409() => View();
}
11 changes: 5 additions & 6 deletions CheckDrive.Web/CheckDrive.Web/Controllers/OilMarksController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CheckDrive.Web.Requests.OilMark;
using CheckDrive.Web.Mappings;
using CheckDrive.Web.Requests.OilMark;
using CheckDrive.Web.Stores.OilMarks;
using Microsoft.AspNetCore.Mvc;

Expand All @@ -20,10 +21,7 @@ public async Task<IActionResult> Details(int id)
return View(oilMark);
}

public IActionResult Create()
{
return View();
}
public IActionResult Create() => View();

[HttpPost]
[ValidateAntiForgeryToken]
Expand All @@ -40,8 +38,9 @@ public async Task<IActionResult> Create([FromForm] CreateOilMarkRequest request)
public async Task<IActionResult> Edit(int id)
{
var oilMark = await oilMarkDataStore.GetByIdAsync(id);
var updateRequest = oilMark.ToUpdateViewModel();

return View(oilMark);
return View(updateRequest);
}

[HttpPost]
Expand Down
34 changes: 3 additions & 31 deletions CheckDrive.Web/CheckDrive.Web/Extensions/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,15 @@
using CheckDrive.Web.Services;
using CheckDrive.Web.Services.CookieHandler;
using CheckDrive.Web.Services.CurrentUserService;
using CheckDrive.Web.Stores.Accounts;
using CheckDrive.Web.Stores.Auth;
using CheckDrive.Web.Stores.Cars;
using CheckDrive.Web.Stores.CheckPoint;
using CheckDrive.Web.Stores.Dashboard;
using CheckDrive.Web.Stores.Debts;
using CheckDrive.Web.Stores.DispatcherReviews;
using CheckDrive.Web.Stores.Dispatchers;
using CheckDrive.Web.Stores.DoctorReviews;
using CheckDrive.Web.Stores.Doctors;
using CheckDrive.Web.Stores.Drivers;
using CheckDrive.Web.Stores.Employee;
using CheckDrive.Web.Stores.MechanicAcceptances;
using CheckDrive.Web.Stores.MechanicHandovers;
using CheckDrive.Web.Stores.Mechanics;
using CheckDrive.Web.Stores.ManagerReview;
using CheckDrive.Web.Stores.Menu;
using CheckDrive.Web.Stores.MockDashboard;
using CheckDrive.Web.Stores.OilMarks;
using CheckDrive.Web.Stores.OperatorReviews;
using CheckDrive.Web.Stores.Operators;
using CheckDrive.Web.Stores.Roles;
using CheckDrive.Web.Stores.Technicians;
using CheckDrive.Web.Stores.User;
using Syncfusion.Licensing;

namespace CheckDrive.Web.Extensions;
Expand Down Expand Up @@ -58,28 +44,14 @@ private static void AddConfigurations(IServiceCollection services, IConfiguratio

private static void AddStores(IServiceCollection services)
{
services.AddScoped<IAccountDataStore, AccountDataStore>();
services.AddScoped<ICarStore, CarStore>();
services.AddScoped<IDispatcherReviewDataStore, DispatcherReviewDataStore>();
services.AddScoped<IDispatcherDataStore, DispatcherDataStore>();
services.AddScoped<IDoctorDataStore, DoctorDataStore>();
services.AddScoped<IDoctorReviewDataStore, DoctorReviewDataStore>();
services.AddScoped<IDriverDataStore, DriverDataStore>();
services.AddScoped<IMechanicAcceptanceDataStore, MechanicAcceptanceDataStore>();
services.AddScoped<IMechanicHandoverDataStore, MechanicHandoverDataStore>();
services.AddScoped<IMechanicDataStore, MechanicDataStore>();
services.AddScoped<IOilMarkStore, OilMarkStore>();
services.AddScoped<IOperatorReviewDataStore, OperatorReviewDataStore>();
services.AddScoped<IOperatorDataStore, OperatorDataStore>();
services.AddScoped<IRoleDataStore, RoleDataStore>();
services.AddScoped<ITechnicianDataStore, MockTechnicianDataStore>();
services.AddScoped<IDashboardStore, DashboardStore>();
services.AddScoped<IMockDashboardStore, MockDashboardStore>();
services.AddScoped<IDebtsStore, DebtsStore>();
services.AddScoped<IUserDataStore, UserDataStore>();
services.AddScoped<ICheckPointStore, CheckPointStore>();
services.AddScoped<IAuthStore, AuthStore>();
services.AddScoped<IEmployeeStore, EmployeeStore>();
services.AddScoped<IManagerReviewStore, ManagerReviewStore>();
}

private static void AddServices(IServiceCollection services)
Expand Down Expand Up @@ -122,4 +94,4 @@ private static void RegisterLicenses(IConfiguration configuration)

SyncfusionLicenseProvider.RegisterLicense(key);
}
}
}
6 changes: 6 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Helpers/AuthorizationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using CheckDrive.Web.Requests.Auth;
using CheckDrive.Web.Services.CookieHandler;
using CheckDrive.Web.Stores.Auth;
using Microsoft.IdentityModel.Tokens;

namespace CheckDrive.Web.Helpers;

Expand Down Expand Up @@ -33,6 +34,11 @@ private async Task TryAddAuthorizationHeadersAsync(HttpRequestMessage request)

var (accessToken, refreshToken) = cookieHandler.GetTokens();

if (accessToken is null || refreshToken is null)
{
throw new SecurityTokenException("Access token or refresh token is missing.");
}

if (JwtHelper.IsValid(accessToken))
{
request.Headers.Authorization = new AuthenticationHeaderValue(HeaderConstants.AuthenticationSchema, accessToken);
Expand Down
Loading