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

bugs fixed, and edit and delete popup #215

Merged
Changes from all commits
Commits
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
14 changes: 8 additions & 6 deletions CheckDrive.Web/CheckDrive.Web/Controllers/AccountsController.cs
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ public async Task<IActionResult> Index(string? searchString, int? roleId, DateTi
{
var accounts = await _accountDataStore.GetAccountsAsync(searchString, roleId, birthDate, pageNumber);

var roles = await GETRoles();
var roles = await GetRolesAsync();

roles.Insert(0, new RoleDto
{
@@ -88,7 +88,7 @@ public async Task<IActionResult> Details(int id)
}
public async Task<IActionResult> Create()
{
var roles = await GETRoles();
var roles = await GetRolesAsync();
ViewBag.Roles = new SelectList(roles, "Id", "Name");
return View();
}
@@ -102,15 +102,17 @@ public async Task<IActionResult> Create([Bind("Login,Password,PhoneNumber,FirstN
var newAccount = await _accountDataStore.CreateAccountAsync(account);
return RedirectToAction("Details", new {id = newAccount.Id});
}
var roles = await GETRoles();
var roles = await GetRolesAsync();
ViewBag.Roles = new SelectList(roles, "Id", "Name");
return View(account);
}

public async Task<IActionResult> Edit(int id)
{
var account = await _accountDataStore.GetAccountAsync(id);

var roles = await GetRolesAsync();
ViewBag.Roles = new SelectList(roles, "Id", "Name");

return View(account);
}

@@ -122,7 +124,7 @@ public async Task<IActionResult> Edit(int id, [Bind("Id,Login,Password,PhoneNumb
if (ModelState.IsValid)
{
var newAccount = await _accountDataStore.UpdateAccountAsync(id, account);
return RedirectToAction("Details", new { id = newAccount.Id });
return RedirectToAction(nameof(Index));
}
return View(account);
}
@@ -145,7 +147,7 @@ public async Task<IActionResult> DeleteConfirmed(int id)
return RedirectToAction(nameof(Index));
}

private async Task<List<RoleDto>> GETRoles()
private async Task<List<RoleDto>> GetRolesAsync()
{
var roleResponse = await _roleStore.GetRoles();
var roles = roleResponse.Data.ToList();
4 changes: 2 additions & 2 deletions CheckDrive.Web/CheckDrive.Web/Controllers/CarsController.cs
Original file line number Diff line number Diff line change
@@ -109,7 +109,7 @@ public async Task<IActionResult> Create([Bind("Model,Color,Number,RemainingFuel,
if (ModelState.IsValid)
{
var newCar = await _carDataStore.CreateCarAsync(car);
return RedirectToAction("Details", new { id = newCar.Id });
return RedirectToAction(nameof(Index));
}
return View(car);
}
@@ -131,7 +131,7 @@ public async Task<IActionResult> Edit(int id, [Bind("Id,Model,Color,Number,Remai
if (ModelState.IsValid)
{
var newCar = await _carDataStore.UpdateCarAsync(id, car);
return RedirectToAction("Details", new { id = newCar.Id });
return RedirectToAction(nameof(Index));
}
return View(car);
}
2 changes: 1 addition & 1 deletion CheckDrive.Web/CheckDrive.Web/Stores/Menu/MenuService.cs
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ public List<Object> GetMenuItems(string role)
{
text = "Yoqilg'ilar",
iconCss = "fa-solid fa-gas-pump",
url = "/#"
url = "/oilMarks"
});

menuItems.Add(new
2 changes: 1 addition & 1 deletion CheckDrive.Web/CheckDrive.Web/Views/Accounts/Create.cshtml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

@{
ViewData["Title"] = "Create";
Layout = null;
Layout = "~/Views/Shared/_LayoutForModal.cshtml";
}
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

85 changes: 16 additions & 69 deletions CheckDrive.Web/CheckDrive.Web/Views/Accounts/Delete.cshtml
Original file line number Diff line number Diff line change
@@ -2,78 +2,25 @@

@{
ViewData["Title"] = "Delete";
Layout = "~/Views/Shared/_Layout.cshtml";
Layout = "~/Views/Shared/_LayoutForModal.cshtml";
}

<h1 class="align-items-baseline" style="margin-top: 100px">O'chirish</h1>
<hr />

<h3 style="color:grey;">Haqiqatan ham buni oʻchirib tashlamoqchimisiz?
O'chirsangiz bu shaxs ishtirok etgan barcha ma'lumotlar ham o'chiriladi!!!
</h3>
<h1 class="text-center mb-5 text-danger"><i class="fa fa-exclamation-circle" style="font-size:100px"></i></h1>
<h4 style="color:grey;">
Haqiqatan ham <b style="color:black;">@Model.FirstName @Model.LastName</b>ni oʻchirib tashlamoqchimisiz?
O'chirsangiz bu shaxs ishtirok etgan barcha ma'lumotlar ham o'chiriladi!!!
</h4>
<div>
<hr/>
<dl class="row">
<dt class="col-sm-2">
Id:
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Id)
</dd>
<dt class="col-sm-2">
Ism:
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.FirstName)
</dd>
<dt class="col-sm-2">
Familiya:
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.LastName)
</dd>
<dt class="col-sm-2">
Tug'ilgan kun:
</dt>
<dd class="col-sm-10">
@(Model.Bithdate.ToString("yyyy-MM-dd"))
</dd>
<dt class="col-sm-2">
Telefon raqam:
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.PhoneNumber)
</dd>
<dt class="col-sm-2">
Login:
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Login)
</dd>
<dt class="col-sm-2">
Parol:
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.Password)
</dd>
<dt class="col-sm-2">
Kasb:
</dt>
<dd class="col-sm-10">
@Html.DisplayFor(model => model.RoleName)
</dd>
</dl>
<!-- Buttons -->
<form asp-action="Delete">
<div class="form-group">
<a asp-action="Index" class="btn btn-outline-info">
<i class="fa-solid fa-arrow-left-long"></i>
Orqaga
</a>
<button asp-route-itemid="@Model.Id" class="btn btn-outline-danger">
<i class="fa-solid fa-trash"></i>
O'chirish
<hr />
<form asp-action="Delete" asp-controller="Accounts">
<div class="d-flex justify-content-center mt-5 m-2" style="gap: 10px;">
<button asp-action="Index" class="btn btn-secondary" style="width:120px">
Yo'q
</button>
<button asp-route-itemid="@Model.Id" class="btn btn-danger" style="width:120px">
Ha
</button>
</div>
</form>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@

@{
ViewData["Title"] = "Details";
Layout = null;
Layout = "~/Views/Shared/_LayoutForModal.cshtml";
}

<div class="nav nav-pills nav-fill" id="nav-tab" role="tablist">
106 changes: 62 additions & 44 deletions CheckDrive.Web/CheckDrive.Web/Views/Accounts/Edit.cshtml
Original file line number Diff line number Diff line change
@@ -1,58 +1,76 @@
@model CheckDrive.ApiContracts.Account.AccountDto

@{
ViewData["Title"] = "Edit";
Layout = "~/Views/Shared/_Layout.cshtml";
ViewData["Title"] = "Edit";
Layout = "~/Views/Shared/_LayoutForModal.cshtml";
}

<h4>Ishchi ma`lumoti</h4>
<hr />
<div class="row">
<div class="col-md-4">
<form asp-action="Edit">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<form id="editAccountForm" asp-action="Edit" method="post" asp-controller="Accounts">
@Html.AntiForgeryToken()
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="row gap-5 ms-4 mb-3">
<div class="col-md-5">
<div>
<label asp-for="FirstName" class="control-label">Ism</label>
<input asp-for="FirstName" class="form-control" />
<span asp-validation-for="FirstName" class="text-danger"></span>
</div>
<div class="form-group">
<input asp-for="FirstName" class="form-control" />
<span asp-validation-for="FirstName" class="text-danger"></span>
</div>
<div class="col-md-5">
<div>
<label asp-for="LastName" class="control-label">Familiya</label>
<input asp-for="LastName" class="form-control" />
<span asp-validation-for="LastName" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Bithdate" class="control-label">Tug'ilgan yil</label>
<input asp-for="Bithdate" type="date" class="form-control" />
<span asp-validation-for="Bithdate" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="PhoneNumber" class="control-label">Telefon raqam</label>
<input asp-for="PhoneNumber" class="form-control" />
<span asp-validation-for="PhoneNumber" class="text-danger"></span>
</div>
<div class="form-group">
<input asp-for="LastName" class="form-control" />
<span asp-validation-for="LastName" class="text-danger"></span>
</div>
</div>
<div class="row gap-5 ms-4 mb-3">
<div class="col-md-5">
<div>
<label asp-for="Login" class="control-label">Login</label>
<input asp-for="Login" class="form-control" />
<span asp-validation-for="Login" class="text-danger"></span>
</div>
<div class="form-group">
<input asp-for="Login" class="form-control" />
<span asp-validation-for="Login" class="text-danger"></span>
</div>
<div class="col-md-5">
<div>
<label asp-for="Password" class="control-label">Parol</label>
<input asp-for="Password" class="form-control" />
<span asp-validation-for="Password" class="text-danger"></span>
</div>
<input asp-for="RoleId" type="hidden" />
<div class="form-group mt-3">
<a asp-action="Details" asp-route-id="@Model?.Id" class="btn btn-outline-info">
<i class="fa-solid fa-arrow-left-long"></i>
Orqaga
</a>
<button class="btn btn-outline-success">
<i class="fa fa-pencil"></i> Saqlash
</button>
<input asp-for="Password" class="form-control" />
<span asp-validation-for="Password" class="text-danger"></span>
</div>
</div>
<div class="row gap-1 ms-4">
<div class="col-md-4">
<div>
<label asp-for="PhoneNumber" class="control-label">Telefon raqam</label>
</div>
<input id="phoneNumberId" class="form-control" asp-for="PhoneNumber" style="height:37.6px; width:160px" />
<span asp-validation-for="PhoneNumber" class="text-danger"></span>
</div>
<div class="col-md-3">
<div>
<label asp-for="Bithdate" class="control-label">Tug'ilgan kun</label>
</div>
<ejs-datepicker id="birthdateId"
class="background"
format="dd/MM/yyyy"
ejs-for="Bithdate"
style="height:36.6px">
</ejs-datepicker>
<span asp-validation-for="Bithdate" class="text-danger"></span>
</div>
<div class="col-md-4">
<div>
<label asp-for="RoleId" class=" control-label">Kasb tanlang</label>
<select name="roleId" asp-for="RoleId" class="form-select form-control border" asp-items="@ViewBag.Roles"></select>
</div>
</form>
</div>
</div>
</div>


<div class="d-flex justify-content-center mb-3 mt-5">
<div class="d-grid w-50">
<button type="submit" id="saveButtonId" class="btn btn-success mr-auto" style="font-size: 14px;">
Saqlash
</button>
</div>
</div>
</form>
Loading