Changeset d6040ef
- Timestamp:
- 08/20/24 23:14:03 (3 months ago)
- Branches:
- main
- Children:
- 57fc402
- Parents:
- 63bd770
- Location:
- PostgreSqlDotnetCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
PostgreSqlDotnetCore/Controllers/BlogController.cs
r63bd770 rd6040ef 11 11 { 12 12 public BlogController(UserManager<IdentityUser> userManager) : base(userManager) 13 { 13 14 { 15 14 16 } 15 17 16 18 // GET: Customer 17 public async Task<ActionResult> IndexAsync() 18 { 19 // check for permission 19 /* public async Task<ActionResult> IndexAsync() 20 { 21 // check for permission 22 bool isAuthenticated = User.Identity.IsAuthenticated; 23 if (!isAuthenticated) 24 { 25 return RedirectToAction("AccessDenied", "Error"); 26 } 27 //return View(Enumerable.Empty<UsersClass>()); 28 return View(db.BlogPostControllerObj.ToList()); 29 } 30 */ 31 32 public async Task<ActionResult> Index() 33 { 34 // Проверка за автентикација 20 35 bool isAuthenticated = User.Identity.IsAuthenticated; 36 21 37 if (!isAuthenticated) 22 38 { 23 39 return RedirectToAction("AccessDenied", "Error"); 24 40 } 25 //return View(Enumerable.Empty<UsersClass>()); 26 return View(db.BlogPostControllerObj.ToList()); 27 } 28 41 42 // Список на блог постови 43 var blogPosts = await db.BlogPostControllerObj.ToListAsync(); 44 45 // Предавање на ViewBag за проверка на автентикација 46 ViewBag.isAuthenticated = isAuthenticated; 47 48 return View(blogPosts); 49 } 29 50 // GET: Customer/Details/5 30 51 public async Task<ActionResult> DetailsAsync(int? id) -
PostgreSqlDotnetCore/Controllers/CityController.cs
r63bd770 rd6040ef 16 16 // GET: Customer 17 17 public async Task<ActionResult> IndexAsync() 18 { 19 // check for permission 20 UsersClass customerClass = await checkAuthorizationAsync(); 21 if (customerClass == null) 22 { 23 return RedirectToAction("AccessDenied", "Error"); 24 } 25 //return View(Enumerable.Empty<UsersClass>()); 26 return View(db.CitiesObj.ToList()); 27 } 18 { 19 // check for permission 20 UsersClass customerClass = await checkAuthorizationAsync(); 21 if (customerClass == null) 22 { 23 return RedirectToAction("AccessDenied", "Error"); 24 } 25 //return View(Enumerable.Empty<UsersClass>()); 26 return View(db.CitiesObj.ToList()); 27 } 28 29 28 30 29 31 // GET: Customer/Details/5 -
PostgreSqlDotnetCore/Controllers/ProductsController.cs
r63bd770 rd6040ef 30 30 // set if is authenticated 31 31 ViewBag.isAuthenticated = await getCrrentUser(); 32 ViewBag.hasAccess = await checkAuthorizationAsync(); 32 33 if (!String.IsNullOrEmpty(searchString)) 33 34 { -
PostgreSqlDotnetCore/Controllers/VetCenterController.cs
r63bd770 rd6040ef 3 3 using Microsoft.EntityFrameworkCore; 4 4 using PostgreSqlDotnetCore.Models; 5 using Microsoft.AspNetCore.Mvc.Rendering; 5 6 using System.Data; 6 7 using System.Net; … … 12 13 public VetCenterController(UserManager<IdentityUser> userManager) : base(userManager) 13 14 { 14 15 // set if is authenticated 16 ViewBag.isAuthenticated = new UsersClass(); 17 } 15 } 16 17 public async Task<ActionResult> Create() 18 { 19 UsersClass customerClass = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin); 20 if (customerClass == null) 21 { 22 return RedirectToAction("AccessDenied", "Error"); 23 } 24 var citiess = await db.CitiesObj.ToListAsync(); 25 26 ViewBag.Citiess = new SelectList(citiess, "id", "name"); 27 28 return View(); 29 } 18 30 19 31 // GET: Customer 32 /* public ActionResult Index() 33 { 34 return View(db.VetCentersObj.ToList()); 35 }*/ 36 20 37 public ActionResult Index() 21 38 { 22 return View(db.VetCentersObj.ToList()); 23 } 39 var vetCenters = db.VetCentersObj.ToList(); 40 41 // Составување на списокот на ветеринарни центри и проверка на автентикацијата 42 ViewBag.isAuthenticated = User.Identity.IsAuthenticated; 43 44 return View(vetCenters); 45 } 46 24 47 25 48 // GET: Customer/Details/5 … … 39 62 40 63 // GET: Customer/Create 41 public async Task<ActionResult> CreateAsync()42 {43 // check for permission44 UsersClass customerClass = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin);45 if (customerClass == null)46 {47 return RedirectToAction("AccessDenied", "Error");48 }49 return View();50 }64 /* public async Task<ActionResult> CreateAsync() 65 { 66 // check for permission 67 UsersClass customerClass = await checkAuthorizationSpecificRoleAsync(RoleConstants.Admin); 68 if (customerClass == null) 69 { 70 return RedirectToAction("AccessDenied", "Error"); 71 } 72 return View(); 73 }*/ 51 74 52 75 // POST: Customer/Create … … 55 78 [HttpPost] 56 79 [ValidateAntiForgeryToken] 80 81 57 82 public ActionResult Create([Bind(include: "id,name,adress,description,workinghours,phonenumber,latitude,longitude,citiesid")] VetCenter vetClass) 58 83 { … … 85 110 return RedirectToAction("AccessDenied", "Error"); 86 111 } 112 var citiess = await db.CitiesObj.ToListAsync(); 113 ViewBag.Citiess = new SelectList(citiess, "id", "name", vetClass.citiesid); 87 114 return View(vetClass); 88 115 } … … 93 120 [HttpPost] 94 121 [ValidateAntiForgeryToken] 95 public ActionResult Edit([Bind(include: "id,name,adress,description,workinghours,phonenumber,latitude,longitude,citiesid")] VetCenter vetClass) 122 /* 123 public ActionResult Edit([Bind(include: "id,name,adress,description,workinghours,phonenumber,latitude,longitude,citiesid")] VetCenter vetClass) 124 { 125 if (ModelState.IsValid) 126 { 127 db.Entry(vetClass).State = EntityState.Modified; 128 db.SaveChanges(); 129 return RedirectToAction("Index"); 130 } 131 return View(vetClass); 132 }*/ 133 134 // POST: VetCenter/Edit/5 135 136 public async Task<ActionResult> Edit([Bind(include: "id,name,adress,description,workinghours,phonenumber,latitude,longitude,citiesid")] VetCenter vetClass) 96 137 { 97 138 if (ModelState.IsValid) 98 139 { 99 140 db.Entry(vetClass).State = EntityState.Modified; 100 db.SaveChanges();141 await db.SaveChangesAsync(); 101 142 return RedirectToAction("Index"); 102 143 } 103 return View(vetClass); 104 } 144 145 var citiess = await db.CitiesObj.ToListAsync(); 146 ViewBag.Citiess = new SelectList(citiess, "id", "name", vetClass.citiesid); 147 148 return View(vetClass); 149 } 150 151 105 152 106 153 // GET: Customer/Delete/5 -
PostgreSqlDotnetCore/Views/Blog/Details.cshtml
r63bd770 rd6040ef 5 5 } 6 6 7 <h2>Details</h2> 8 7 @*<h2>Одговори</h2>*@ 8 @* 9 9 <div> 10 10 <h4>Blog post for consultations</h4> 11 11 <hr /> 12 12 <dl class="dl-horizontal"> … … 33 33 @Html.DisplayFor(model => model.description) 34 34 </dd> 35 35 36 <dt> 36 37 @Html.DisplayNameFor(model => model.users_id) … … 41 42 </dd> 42 43 44 43 45 </dl> 44 46 </div> 47 *@ 48 45 49 <hr/> 46 50 <div> 47 <h 4>Blog post anwers</h4>51 <h2>Answers</h2> 48 52 <hr /> 49 53 -
PostgreSqlDotnetCore/Views/Blog/Index.cshtml
r63bd770 rd6040ef 47 47 <td> 48 48 @Html.ActionLink("Edit", "Edit", new { id = item.id }) | 49 @Html.ActionLink(" Details", "Details", new { id = item.id }) |49 @Html.ActionLink("Answers", "Details", new { id = item.id }) | 50 50 @Html.ActionLink("Delete", "Delete", new { id = item.id }) 51 51 </td> -
PostgreSqlDotnetCore/Views/Products/Index.cshtml
r63bd770 rd6040ef 60 60 </style> 61 61 <h2>All type of products</h2> 62 @if (SignInManager.IsSignedIn(User) )62 @if (SignInManager.IsSignedIn(User) && ViewBag.hasAccess != null) 63 63 { 64 64 <p> -
PostgreSqlDotnetCore/Views/VetCenter/Create.cshtml
r63bd770 rd6040ef 8 8 9 9 10 @using (Html.BeginForm()) 10 @using (Html.BeginForm()) 11 11 { 12 12 @Html.AntiForgeryToken() 13 14 <div class="form-horizontal"> 15 <h4>VetCenter</h4> 16 <hr /> 17 @Html.ValidationSummary(true, "", new { @class = "text-danger" }) 18 <div class="form-group"> 19 @Html.LabelFor(model => model.name, htmlAttributes: new { @class = "control-label col-md-2" }) 20 <div class="col-md-10"> 21 @Html.EditorFor(model => model.name, new { htmlAttributes = new { @class = "form-control" } }) 22 @Html.ValidationMessageFor(model => model.name, "", new { @class = "text-danger" }) 13 14 <div class="form-horizontal"> 15 <h4>VetCenter</h4> 16 <hr /> 17 @Html.ValidationSummary(true, "", new { @class = "text-danger" }) 18 <div class="form-group"> 19 @Html.LabelFor(model => model.name, htmlAttributes: new { @class = "control-label col-md-2" }) 20 <div class="col-md-10"> 21 @Html.EditorFor(model => model.name, new { htmlAttributes = new { @class = "form-control" } }) 22 @Html.ValidationMessageFor(model => model.name, "", new { @class = "text-danger" }) 23 </div> 24 </div> 25 26 <div class="form-group"> 27 @Html.LabelFor(model => model.adress, htmlAttributes: new { @class = "control-label col-md-2" }) 28 <div class="col-md-10"> 29 @Html.EditorFor(model => model.adress, new { htmlAttributes = new { @class = "form-control" } }) 30 @Html.ValidationMessageFor(model => model.adress, "", new { @class = "text-danger" }) 31 </div> 32 </div> 33 <div class="form-group"> 34 @Html.LabelFor(model => model.description, htmlAttributes: new { @class = "control-label col-md-2" }) 35 <div class="col-md-10"> 36 @Html.EditorFor(model => model.description, new { htmlAttributes = new { @class = "form-control" } }) 37 @Html.ValidationMessageFor(model => model.description, "", new { @class = "text-danger" }) 38 </div> 39 </div> 40 <div class="form-group"> 41 @Html.LabelFor(model => model.workinghours, htmlAttributes: new { @class = "control-label col-md-2" }) 42 <div class="col-md-10"> 43 @Html.EditorFor(model => model.workinghours, new { htmlAttributes = new { @class = "form-control" } }) 44 @Html.ValidationMessageFor(model => model.workinghours, "", new { @class = "text-danger" }) 45 </div> 46 </div> 47 48 <div class="form-group"> 49 @Html.LabelFor(model => model.phonenumber, htmlAttributes: new { @class = "control-label col-md-2" }) 50 <div class="col-md-10"> 51 @Html.EditorFor(model => model.phonenumber, new { htmlAttributes = new { @class = "form-control" } }) 52 @Html.ValidationMessageFor(model => model.phonenumber, "", new { @class = "text-danger" }) 53 </div> 54 </div> 55 <div class="form-group"> 56 @Html.LabelFor(model => model.latitude, htmlAttributes: new { @class = "control-label col-md-2" }) 57 <div class="col-md-10"> 58 @Html.EditorFor(model => model.latitude, new { htmlAttributes = new { @class = "form-control" } }) 59 @Html.ValidationMessageFor(model => model.latitude, "", new { @class = "text-danger" }) 60 </div> 61 </div> 62 <div class="form-group"> 63 @Html.LabelFor(model => model.longitude, htmlAttributes: new { @class = "control-label col-md-2" }) 64 <div class="col-md-10"> 65 @Html.EditorFor(model => model.longitude, new { htmlAttributes = new { @class = "form-control" } }) 66 @Html.ValidationMessageFor(model => model.longitude, "", new { @class = "text-danger" }) 67 </div> 68 </div> 69 @*<div class="form-group"> 70 @Html.LabelFor(model => model.citiesid, htmlAttributes: new { @class = "control-label col-md-2" }) 71 <div class="col-md-10"> 72 @Html.EditorFor(model => model.citiesid, new { htmlAttributes = new { @class = "form-control" } }) 73 @Html.ValidationMessageFor(model => model.citiesid, "", new { @class = "text-danger" }) 74 </div> 75 </div>*@ 76 77 @* <div class="form-group"> 78 <label for="citiesid">Citie:</label> 79 <select class="form-control" id="citiesid" name="citiesid"> 80 <option value="">Select city</option> 81 <option value="1">Скопје</option> 82 <option value="1">Охрид</option> 83 <option value="1">Скопје</option> 84 <option value="1">Берово</option> 85 <option value="2">Битола</option> 86 <option value="3">Богданци</option> 87 <option value="4">Валандово</option> 88 <option value="5">Велес</option> 89 <option value="6">Виница</option> 90 <option value="7">Гевгелија</option> 91 <option value="8">Гостивар</option> 92 <option value="9">Дебар</option> 93 <option value="10">Делчево</option> 94 <option value="11">Демир Капија</option> 95 <option value="12">Демир Хисар</option> 96 <option value="13">Кавадарци</option> 97 <option value="14">Кичево</option> 98 <option value="15">Кочани</option> 99 <option value="16">Кратово</option> 100 <option value="17">Крива Паланка</option> 101 <option value="18">Крушево</option> 102 <option value="19">Куманово</option> 103 <option value="20">Македонска Каменица</option> 104 <option value="21">Македонски Брод</option> 105 <option value="22">Неготино</option> 106 <option value="23">Охрид</option> 107 <option value="24">Пехчево</option> 108 <option value="25">Прилеп</option> 109 <option value="26">Пропиштип</option> 110 <option value="27">Радовиш</option> 111 <option value="28">Ресен</option> 112 <option value="29">Свети Николе</option> 113 <option value="30">Скопје</option> 114 <option value="31">Струга</option> 115 <option value="32">Струмица</option> 116 <option value="33">Тетово</option> 117 <option value="34">Штип</option> 118 </select> 119 </div> 120 *@ 121 122 <div class="form-group"> 123 <label asp-for="citiesid" class="control-label"></label> 124 <select asp-for="citiesid" asp-items="ViewBag.Citiess" class="form-control"></select> 125 <span asp-validation-for="citiesid" class="text-danger"></span> 126 </div> 127 <div class="form-group"> 128 <div class="col-md-offset-2 col-md-10"> 129 <input type="submit" value="Create" class="btn btn-default" /> 130 </div> 23 131 </div> 24 132 </div> 25 26 <div class="form-group">27 @Html.LabelFor(model => model.adress, htmlAttributes: new { @class = "control-label col-md-2" })28 <div class="col-md-10">29 @Html.EditorFor(model => model.adress, new { htmlAttributes = new { @class = "form-control" } })30 @Html.ValidationMessageFor(model => model.adress, "", new { @class = "text-danger" })31 </div>32 </div>33 <div class="form-group">34 @Html.LabelFor(model => model.description, htmlAttributes: new { @class = "control-label col-md-2" })35 <div class="col-md-10">36 @Html.EditorFor(model => model.description, new { htmlAttributes = new { @class = "form-control" } })37 @Html.ValidationMessageFor(model => model.description, "", new { @class = "text-danger" })38 </div>39 </div>40 <div class="form-group">41 @Html.LabelFor(model => model.workinghours, htmlAttributes: new { @class = "control-label col-md-2" })42 <div class="col-md-10">43 @Html.EditorFor(model => model.workinghours, new { htmlAttributes = new { @class = "form-control" } })44 @Html.ValidationMessageFor(model => model.workinghours, "", new { @class = "text-danger" })45 </div>46 </div>47 48 <div class="form-group">49 @Html.LabelFor(model => model.phonenumber, htmlAttributes: new { @class = "control-label col-md-2" })50 <div class="col-md-10">51 @Html.EditorFor(model => model.phonenumber, new { htmlAttributes = new { @class = "form-control" } })52 @Html.ValidationMessageFor(model => model.phonenumber, "", new { @class = "text-danger" })53 </div>54 </div>55 <div class="form-group">56 @Html.LabelFor(model => model.latitude, htmlAttributes: new { @class = "control-label col-md-2" })57 <div class="col-md-10">58 @Html.EditorFor(model => model.latitude, new { htmlAttributes = new { @class = "form-control" } })59 @Html.ValidationMessageFor(model => model.latitude, "", new { @class = "text-danger" })60 </div>61 </div>62 <div class="form-group">63 @Html.LabelFor(model => model.longitude, htmlAttributes: new { @class = "control-label col-md-2" })64 <div class="col-md-10">65 @Html.EditorFor(model => model.longitude, new { htmlAttributes = new { @class = "form-control" } })66 @Html.ValidationMessageFor(model => model.longitude, "", new { @class = "text-danger" })67 </div>68 </div>69 @*<div class="form-group">70 @Html.LabelFor(model => model.citiesid, htmlAttributes: new { @class = "control-label col-md-2" })71 <div class="col-md-10">72 @Html.EditorFor(model => model.citiesid, new { htmlAttributes = new { @class = "form-control" } })73 @Html.ValidationMessageFor(model => model.citiesid, "", new { @class = "text-danger" })74 </div>75 </div>*@76 77 <div class="form-group">78 <label for="citiesid">Citie:</label>79 <select class="form-control" id="citiesid" name="citiesid">80 <option value="">Select city</option>81 <option value="1">Скопје</option>82 <option value="1">Охрид</option>83 <option value="1">Скопје</option>84 @* <option value="1">Берово</option>85 <option value="2">Битола</option>86 <option value="3">Богданци</option>87 <option value="4">Валандово</option>88 <option value="5">Велес</option>89 <option value="6">Виница</option>90 <option value="7">Гевгелија</option>91 <option value="8">Гостивар</option>92 <option value="9">Дебар</option>93 <option value="10">Делчево</option>94 <option value="11">Демир Капија</option>95 <option value="12">Демир Хисар</option>96 <option value="13">Кавадарци</option>97 <option value="14">Кичево</option>98 <option value="15">Кочани</option>99 <option value="16">Кратово</option>100 <option value="17">Крива Паланка</option>101 <option value="18">Крушево</option>102 <option value="19">Куманово</option>103 <option value="20">Македонска Каменица</option>104 <option value="21">Македонски Брод</option>105 <option value="22">Неготино</option>106 <option value="23">Охрид</option>107 <option value="24">Пехчево</option>108 <option value="25">Прилеп</option>109 <option value="26">Пропиштип</option>110 <option value="27">Радовиш</option>111 <option value="28">Ресен</option>112 <option value="29">Свети Николе</option>113 <option value="30">Скопје</option>114 <option value="31">Струга</option>115 <option value="32">Струмица</option>116 <option value="33">Тетово</option>117 <option value="34">Штип</option> *@118 </select>119 </div>120 121 <div class="form-group">122 <div class="col-md-offset-2 col-md-10">123 <input type="submit" value="Create" class="btn btn-default" />124 </div>125 </div>126 </div>127 133 } 128 134 -
PostgreSqlDotnetCore/Views/VetCenter/Edit.cshtml
r63bd770 rd6040ef 75 75 </div> 76 76 </div> *@ 77 <div class="form-group">77 @* <div class="form-group"> 78 78 <label for="citiesid">Citie:</label> 79 79 <select class="form-control" id="citiesid" name="citiesid"> … … 84 84 </select> 85 85 </div> 86 86 *@ 87 <div class="form-group"> 88 <label asp-for="citiesid" class="control-label"></label> 89 <select asp-for="citiesid" asp-items="ViewBag.Citiess" class="form-control"></select> 90 <span asp-validation-for="citiesid" class="text-danger"></span> 91 </div> 87 92 88 93 <div class="form-group">
Note:
See TracChangeset
for help on using the changeset viewer.