diff --git a/BL/BL.csproj b/BL/BL.csproj
deleted file mode 100644
index fa71b7a..0000000
--- a/BL/BL.csproj
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
- net8.0
- enable
- enable
-
-
-
diff --git a/BL/Class1.cs b/BL/Class1.cs
deleted file mode 100644
index 95d54c3..0000000
--- a/BL/Class1.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace BL
-{
- public class Class1
- {
-
- }
-}
diff --git a/DTOs/CategoryDto.cs b/DTOs/CategoryDto.cs
index 53c2417..17b4676 100644
--- a/DTOs/CategoryDto.cs
+++ b/DTOs/CategoryDto.cs
@@ -8,9 +8,5 @@ public class CategoryDto
public int? CategoryId { get; set; }
public string? CategoryName { get; set; }
-
- //public List productId { get; set; } = new List();
-
- //public virtual ICollection Products { get; set; } = new List();
}
}
\ No newline at end of file
diff --git a/DTOs/Class1.cs b/DTOs/Class1.cs
deleted file mode 100644
index 717ef90..0000000
--- a/DTOs/Class1.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace DTO
-{
- public class Class1
- {
-
- }
-}
diff --git a/DTOs/OrderDto.cs b/DTOs/OrderDto.cs
index 60da3bf..821a97b 100644
--- a/DTOs/OrderDto.cs
+++ b/DTOs/OrderDto.cs
@@ -5,17 +5,11 @@ namespace DTO;
public partial class OrderDto
{
- //public int OrderId { get; set; }
-
- //public DateOnly? OrderDate { get; set; }
public int OrderSum { get; set; }
public int UserId { get; set; }
- //public List OrderItems { get; set; } = new List();
-
public virtual ICollection OrderItems { get; set; } = new List();
- //public virtual User User { get; set; } = null!;
}
diff --git a/DTOs/OrderItemDto.cs b/DTOs/OrderItemDto.cs
index 9e0fb65..77e14fb 100644
--- a/DTOs/OrderItemDto.cs
+++ b/DTOs/OrderItemDto.cs
@@ -6,16 +6,9 @@ namespace DTO;
public partial class OrderItemDto
{
- //public int OrderItemId { get; set; }
-
public int? ProductId { get; set; }
- //public int OrderId { get; set; }
-
public int? Quaninty { get; set; }
- //public virtual Order Order { get; set; } = null!;
-
- //public virtual Product Product { get; set; } = null!;
}
diff --git a/DTOs/ProductDto.cs b/DTOs/ProductDto.cs
index 870b1ef..764f040 100644
--- a/DTOs/ProductDto.cs
+++ b/DTOs/ProductDto.cs
@@ -17,7 +17,4 @@ public class ProductDto
public string? Picture { get; set; }
- //public virtual Category? Category { get; set; }
-
- //public virtual ICollection OrderItems { get; set; } = new List();
}
diff --git a/DTOs/UserLoginDto.cs b/DTOs/UserLoginDto.cs
index d44fd2c..d065a7e 100644
--- a/DTOs/UserLoginDto.cs
+++ b/DTOs/UserLoginDto.cs
@@ -11,6 +11,7 @@ public class UserLoginDto
{
[EmailAddress]
public string Email { get; set; }
+
[MaxLength(20)]
public string? Password { get; set; }
}
diff --git a/DTOs/UserRegister.cs b/DTOs/UserRegister.cs
index fc36cc0..9e17970 100644
--- a/DTOs/UserRegister.cs
+++ b/DTOs/UserRegister.cs
@@ -11,6 +11,7 @@ public class UserRegister
{
[EmailAddress]
public string? Email { get; set; }
+
[MaxLength(20)]
public string? FirstName { get; set; }
diff --git a/DTOs/UserUpdate.cs b/DTOs/UserUpdate.cs
index a580257..5c8246c 100644
--- a/DTOs/UserUpdate.cs
+++ b/DTOs/UserUpdate.cs
@@ -9,9 +9,10 @@ namespace DTO;
public class UserUpdate
{
- //public int UserId { get; set; }
+
[EmailAddress]
public string? Email { get; set; }
+
[MaxLength(20)]
public string? FirstName { get; set; }
diff --git a/Entities/OrderItem.cs b/Entities/OrderItem.cs
index defdd35..07c631b 100644
--- a/Entities/OrderItem.cs
+++ b/Entities/OrderItem.cs
@@ -14,8 +14,10 @@ public class OrderItem
public int OrderId { get; set; }
public int Quaninty { get; set; }
+
[JsonIgnore]
public virtual Order? Order { get; set; } = null!;
+
[JsonIgnore]
public virtual Product? Product { get; set; } = null!;
}
diff --git a/Entities/Rating.cs b/Entities/Rating.cs
index 51b883b..d4c1227 100644
--- a/Entities/Rating.cs
+++ b/Entities/Rating.cs
@@ -6,11 +6,17 @@ namespace Entities
public partial class Rating
{
public int RatingId { get; set; }
+
public string Host { get; set; }
+
public string Method { get; set; }
+
public string Path { get; set; }
+
public string Referer { get; set; }
+
public string UserAgent { get; set; }
+
public DateTime? RecordDate { get; set; }
}
}
diff --git a/Entities/User.cs b/Entities/User.cs
index 7baf08d..41f04ae 100644
--- a/Entities/User.cs
+++ b/Entities/User.cs
@@ -7,8 +7,10 @@ namespace Repositories;
public class User
{
public int UserId { get; set; }
+
[EmailAddress]
public string? Email { get; set; }
+
[MaxLength(20)]
public string? FirstName { get; set; }
diff --git a/LoginProject/Controllers/ProductController.cs b/LoginProject/Controllers/ProductController.cs
index 92dfb0b..86dc082 100644
--- a/LoginProject/Controllers/ProductController.cs
+++ b/LoginProject/Controllers/ProductController.cs
@@ -4,8 +4,6 @@
using Services;
using System.Collections.Generic;
-// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
-
namespace LoginProject.Controllers
{
[Route("api/[controller]")]
diff --git a/LoginProject/Controllers/categoryController.cs b/LoginProject/Controllers/categoryController.cs
index 0565038..bd8da79 100644
--- a/LoginProject/Controllers/categoryController.cs
+++ b/LoginProject/Controllers/categoryController.cs
@@ -5,8 +5,6 @@
using Services;
using System.Collections.Generic;
-// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
-
namespace LoginProject.Controllers
{
[Route("api/[controller]")]
@@ -42,7 +40,5 @@ public async Task> GetById(int id)
return NotFound();
return Ok(categoryDto);
}
-
-
}
}
diff --git a/LoginProject/Controllers/orderController .cs b/LoginProject/Controllers/orderController .cs
index acdfcc4..6534fea 100644
--- a/LoginProject/Controllers/orderController .cs
+++ b/LoginProject/Controllers/orderController .cs
@@ -5,8 +5,6 @@
using Services;
using System.Collections.Generic;
-// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
-
namespace LoginProject.Controllers
{
[Route("api/[controller]")]
diff --git a/LoginProject/Controllers/usersController.cs b/LoginProject/Controllers/usersController.cs
index 65527fc..7dc7ec5 100644
--- a/LoginProject/Controllers/usersController.cs
+++ b/LoginProject/Controllers/usersController.cs
@@ -1,14 +1,11 @@
using Services;
using Microsoft.AspNetCore.Mvc;
using System.Text.Json;
-//using Entities;
using Microsoft.AspNetCore.Identity;
using Repositories;
using DTO;
using AutoMapper;
-// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
-
namespace LoginProject.Controllers
{
diff --git a/LoginProject/MiddleWare/ErrorHandlingMiddleware.cs b/LoginProject/MiddleWare/ErrorHandlingMiddleware.cs
index 210918c..4d38de9 100644
--- a/LoginProject/MiddleWare/ErrorHandlingMiddleware.cs
+++ b/LoginProject/MiddleWare/ErrorHandlingMiddleware.cs
@@ -4,7 +4,6 @@
namespace PresidentsApp.Middlewares
{
- // You may need to install the Microsoft.AspNetCore.Http.Abstractions package into your project
public class ErrorHandlingMiddleware
{
private readonly RequestDelegate _next;
diff --git a/LoginProject/MiddleWare/RatingMiddleware.cs b/LoginProject/MiddleWare/RatingMiddleware.cs
index 9676315..4fb9cb5 100644
--- a/LoginProject/MiddleWare/RatingMiddleware.cs
+++ b/LoginProject/MiddleWare/RatingMiddleware.cs
@@ -7,7 +7,6 @@
namespace LoginProject.MiddleWare
{
- // You may need to install the Microsoft.AspNetCore.Http.Abstractions package into your project
public class RatingMiddleware
{
private readonly RequestDelegate _next;
diff --git a/LoginProject/Users.txt b/LoginProject/Users.txt
deleted file mode 100644
index af759f3..0000000
--- a/LoginProject/Users.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-{"UserId":7,"FirstName":"xx","LastName":"qq","Email":"mm@gmail.com","Password":"ww"}
-{"UserId":2,"FirstName":"w","LastName":"w","Email":"f@gmail.com","Password":"123"}
-{"UserId":3,"FirstName":"e","LastName":"s","Email":"e@gmail.com","Password":"1111"}
-{"UserId":4,"FirstName":"gg","LastName":"gg","Email":"e@gmail.com","Password":"11111"}
-{"UserId":5,"FirstName":"","LastName":"","Email":"f@gmail","Password":"1dkljo; vbo;uUJwyhuiyh7@lkf;"}
-{"UserId":6,"FirstName":"","LastName":"","Email":"f@gmail","Password":"1dkljo; vbo;uUJwyhuiyh7@lkf;"}
-{"UserId":7,"FirstName":"","LastName":"","Email":"f@gmail.com","Password":"yyyyyui8v 87 vcSdtgrcyt8gb98b c cc"}
-{"UserId":8,"FirstName":"hh","LastName":"gg","Email":"w@gmail.com","Password":"lkjh5968595286"}
-{"UserId":9,"FirstName":"","LastName":"","Email":"f@gmail.com","Password":"1w3r5y7i"}
-{"UserId":10,"FirstName":"","LastName":"","Email":"f@gmail.com","Password":"1w3r5y7i"}
-{"UserId":11,"FirstName":"","LastName":"","Email":"f@gmail.com","Password":"1w3r5y7i"}
-{"UserId":12,"FirstName":"","LastName":"","Email":"f@gmail.com","Password":"1w3r5y7i"}
-{"UserId":13,"FirstName":"","LastName":"","Email":"f@gmail.com","Password":"1w3r5y7i"}
-{"UserId":14,"FirstName":"","LastName":"","Email":"f@gmail.com","Password":"1w3r5y7i"}
-{"UserId":15,"FirstName":"","LastName":"","Email":"f@gmail.com","Password":"1w3r5y7i"}
-{"UserId":16,"FirstName":"","LastName":"","Email":"f@gmail.com","Password":"1w3r5y7i"}
-{"UserId":17,"FirstName":"","LastName":"","Email":"f@gmail.com","Password":"1w3r5y7i"}
-{"UserId":18,"FirstName":"","LastName":"","Email":"f@gmail.com","Password":"1w3r5y7i"}
-{"UserId":19,"FirstName":"","LastName":"","Email":"f@gmail.com","Password":"1w3r5y7i"}
-{"UserId":20,"FirstName":"","LastName":"","Email":"f@gmail.com","Password":"1w3r5y7i"}
-{"UserId":21,"FirstName":"","LastName":"","Email":"f@gmail.com","Password":"1w3r5y7i"}
-{"UserId":22,"FirstName":"","LastName":"","Email":"f@gmail.com","Password":"1w3r5y7i"}
-{"UserId":23,"FirstName":"","LastName":"","Email":"f@gmail.com","Password":""}
-{"UserId":24,"FirstName":"","LastName":"","Email":"f@gmail.com","Password":""}
-{"UserId":25,"FirstName":"","LastName":"","Email":"f@gmail.com","Password":""}
-{"UserId":26,"FirstName":"","LastName":"","Email":"f@gmail.com","Password":""}
-{"UserId":27,"FirstName":"","LastName":"","Email":"f@gmail.com","Password":""}
-{"UserId":28,"FirstName":"tttttttttttttt","LastName":"tttttttttttttt","Email":"f@gmail.com","Password":"asaw"}
-{"UserId":29,"FirstName":"","LastName":"","Email":"5@mby.co.il","Password":"ll;k;l[p"}
-{"UserId":30,"FirstName":"","LastName":"","Email":"5@mby.co.il","Password":"klklkoo9"}
-{"UserId":31,"FirstName":"","LastName":"","Email":"5@mby.co.il","Password":"klklkoo9"}
-{"UserId":32,"FirstName":"","LastName":"","Email":"5@mby.co.il","Password":"klklkoo9"}
-{"UserId":33,"FirstName":"","LastName":"","Email":"5@mby.co.il","Password":"klklkoo9"}
-{"UserId":34,"FirstName":"","LastName":"","Email":"5@mby.co.il","Password":"klklkoo9"}
-{"UserId":35,"FirstName":"","LastName":"","Email":"5@mby.co.il","Password":"klklkoo9"}
-{"UserId":36,"FirstName":"","LastName":"","Email":"5@mby.co.il","Password":"klklkoo9"}
-{"UserId":37,"FirstName":"","LastName":"","Email":"5@mby.co.il","Password":"klklkoo9"}
-{"UserId":38,"FirstName":"","LastName":"","Email":"5@mby.co.il","Password":"klklkoo9"}
-{"UserId":39,"FirstName":"","LastName":"","Email":"5@mby.co.il","Password":"klklkoo9"}
-{"UserId":40,"FirstName":"","LastName":"","Email":"5@mby.co.il","Password":"klklkoo9"}
-{"UserId":41,"FirstName":"","LastName":"","Email":"5@mby.co.il","Password":"yum,5d8, n87"}
diff --git a/Repositories/CategotyRepository.cs b/Repositories/CategotyRepository.cs
index 9e30653..d1403b1 100644
--- a/Repositories/CategotyRepository.cs
+++ b/Repositories/CategotyRepository.cs
@@ -27,34 +27,6 @@ public Task getCategoryById(int id)
{
throw new NotImplementedException();
}
- //public async Task> getProducts(int position,int skip,string? desc,int? minPrice
- // ,int maxPrice, int?[] categoryIds )
- //{
- // var query = _photoGalleryContext.Products.Where(product=>
- // (desc==null ? (true) : (product.Description.Contains(desc)))
- // && ((minPrice==null)? (true) :(product.Price >= minPrice))
- // && ((maxPrice==null)? (true) : (product.Price<= maxPrice))
- // &&((categoryIds.Length==0) ? (true) : (categoryIds.Contains(product.CategoryId))))
- // .OrderBy(Product => Product.Price);
- // //.Skip((position-1)*skip)
- // //.Take(skip);
- // Console.WriteLine(query.ToQueryString());
- // List products = await query.ToListAsync();
- // return products;
-
-
-
- // ;
-
- //}
-
- //public async Task getProductById(int id)
- //{
- // var foundProduct = await _photoGalleryContext.Products.FindAsync(id);
- // if (foundProduct == null)
- // return null;
- // return foundProduct;
- //}
-
+
}
}
diff --git a/Repositories/ICategoryRepository .cs b/Repositories/ICategoryRepository .cs
index 5fb4339..ba1ce29 100644
--- a/Repositories/ICategoryRepository .cs
+++ b/Repositories/ICategoryRepository .cs
@@ -6,9 +6,9 @@ namespace Repositories
{
public interface ICategoryRepository
{
- //Task addUser(User user);
Task getCategoryById(int id);
+
Task> getCategories();
- //Task updateUser(int id, User userToUpdate);
+
}
}
\ No newline at end of file
diff --git a/Repositories/IOrderItemRepository.cs b/Repositories/IOrderItemRepository.cs
index a306734..23dae42 100644
--- a/Repositories/IOrderItemRepository.cs
+++ b/Repositories/IOrderItemRepository.cs
@@ -6,7 +6,8 @@ namespace Repositories
public interface IOrderItemRepository
{
OrderItem addOrderItem(OrderItemDto orderItemDto);
+
Task> getAllOrderItems();
- //Task updateUser(int id, User userToUpdate);
+
}
}
\ No newline at end of file
diff --git a/Repositories/IOrderrRepository .cs b/Repositories/IOrderrRepository .cs
index 3e94630..1980264 100644
--- a/Repositories/IOrderrRepository .cs
+++ b/Repositories/IOrderrRepository .cs
@@ -6,6 +6,5 @@ namespace Repositories
public interface IOrderRepository
{
Task addOrder(Order order);
-
}
}
\ No newline at end of file
diff --git a/Repositories/IUserRepository.cs b/Repositories/IUserRepository.cs
index edf8890..3174a4f 100644
--- a/Repositories/IUserRepository.cs
+++ b/Repositories/IUserRepository.cs
@@ -6,8 +6,9 @@ namespace Repositories
public interface IUserRepository
{
Task addUser(User user);
+
Task GetUserByEmailAndPassword(User userLoginDto);
- //Task getUserById(int id);
+
Task updateUser(int id, User userToUpdate);
}
}
\ No newline at end of file
diff --git a/Repositories/OrderItemRepository .cs b/Repositories/OrderItemRepository .cs
deleted file mode 100644
index cc74a4a..0000000
--- a/Repositories/OrderItemRepository .cs
+++ /dev/null
@@ -1,110 +0,0 @@
-//using Entities;
-//using Microsoft.EntityFrameworkCore;
-//using System.Text.Json;
-
-//namespace Repositories
-
-//{
-// public class UserRepository : IUserRepository
-// {
-// private PhotoGalleryContext _photoGalleryContext;
-// public UserRepository(PhotoGalleryContext photoGalleryContext)
-// {
-// _photoGalleryContext = photoGalleryContext;
-// }
-// public async Task getUserById(int id)
-// {
-// var foundUser = await _photoGalleryContext.Users.FindAsync(id);
-// if (foundUser == null)
-// return null;
-// return foundUser;
-
-// //using (StreamReader reader = System.IO.File.OpenText("../Users.txt"))
-// //{
-// // string? currentUserInFile;
-// // while ((currentUserInFile = reader.ReadLine()) != null)
-// // {
-// // User user = JsonSerializer.Deserialize(currentUserInFile);
-// // if (user.UserId == id)
-// // return user;
-
-// // }
-// // return null;
-// //}
-// }
-// public async Task GetUserByEmailAndPassword(UserLogin userLogin)
-// {
-// var s= await _photoGalleryContext.Users.Where(e => e.Email == userLogin.Email && e.Password == userLogin.Password).FirstOrDefaultAsync();
-// return s;
-
-// //using (StreamReader reader = System.IO.File.OpenText("Users.txt"))
-// //{
-// // string? currentUserInFile;
-// // while ((currentUserInFile = reader.ReadLine()) != null)
-// // {
-// // User user = JsonSerializer.Deserialize(currentUserInFile);
-// // if (user.Email == userLogin.Email && user.Password == userLogin.Password)
-// // return user;
-// // }
-
-// //}
-// //return null;
-// }
-
-// public async Task addUser(User user)
-// {
-// try {
-// await _photoGalleryContext.Users.AddAsync(user);
-// await _photoGalleryContext.SaveChangesAsync();
-// return user;
-// }
-// catch(Exception ex)
-// {
-// throw ex;
-// }
-// //Console.WriteLine("register");
-// //string filePath = "Users.txt";
-// //int numberOfUsers = System.IO.File.ReadLines(filePath).Count();
-// //user.UserId = numberOfUsers + 1;
-// //string userJson = JsonSerializer.Serialize(user);
-// //System.IO.File.AppendAllText(filePath, userJson + Environment.NewLine);
-// //return user;
-
-// }
-// public async Task updateUser(int id, User userToUpdate)
-// {
-// var foundUser = await _photoGalleryContext.Users.FindAsync(id);
-// if (foundUser == null)
-// return null;
-// _photoGalleryContext.Entry(foundUser).CurrentValues.SetValues(userToUpdate);
-// await _photoGalleryContext.SaveChangesAsync();
-// return userToUpdate;
-// }
-// // string textToReplace = string.Empty;
-// // string filePath = " Users.txt";
-// // using (StreamReader reader = System.IO.File.OpenText("Users.txt"))
-// // {
-// // string currentUserInFile;
-// // while ((currentUserInFile = reader.ReadLine()) != null)
-// // {
-
-// // User user = JsonSerializer.Deserialize(currentUserInFile);
-// // if (user.UserId == id)
-// // textToReplace = currentUserInFile;
-// // }
-// // }
-
-// // if (textToReplace != string.Empty)
-// // {
-// // string text = System.IO.File.ReadAllText("Users.txt");
-// // text = text.Replace(textToReplace, JsonSerializer.Serialize(userToUpdate));
-// // System.IO.File.WriteAllText("Users.txt", text);
-// // return true;
-// // }
-// // return false;
-
-// //}
-
-
-// }
-//}
diff --git a/Repositories/OrderRepository.cs b/Repositories/OrderRepository.cs
index 08dc7c5..aa486fa 100644
--- a/Repositories/OrderRepository.cs
+++ b/Repositories/OrderRepository.cs
@@ -13,9 +13,6 @@ public OrderRepository(PhotoGalleryContext photoGalleryContext)
_photoGalleryContext = photoGalleryContext;
}
-
-
-
public async Task addOrder(Order order)
{
await _photoGalleryContext.Orders.AddAsync(order);
@@ -23,6 +20,5 @@ public async Task addOrder(Order order)
return order;
}
-
}
}
diff --git a/Repositories/UserRepository.cs b/Repositories/UserRepository.cs
index 784060b..586a0b1 100644
--- a/Repositories/UserRepository.cs
+++ b/Repositories/UserRepository.cs
@@ -1,7 +1,6 @@
using DTO;
using Microsoft.EntityFrameworkCore;
using System.Text.Json;
-
namespace Repositories
{
@@ -21,9 +20,7 @@ public async Task GetUserByEmailAndPassword(User userLogin)
}
public async Task addUser(User user)
- {
-
-
+ {
await _photoGalleryContext.Users.AddAsync(user);
await _photoGalleryContext.SaveChangesAsync();
return user;
diff --git a/Repositories/Users.txt b/Repositories/Users.txt
deleted file mode 100644
index 34d3932..0000000
--- a/Repositories/Users.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-{"UserId":1,"FirstName":"hh","LastName":"q","Email":"huuu@gmail.com","Password":"mmmmm"}
-{"UserId":2,"FirstName":"Shani","LastName":"Strauss","Email":"h@gmail.co","Password":"rr"}
-{"UserId":3,"FirstName":"Shani","LastName":"Strauss","Email":"h@gmail.co","Password":"rr"}
-{"UserId":4,"FirstName":"Shani","LastName":"Strauss","Email":"h@gmail.co","Password":"rr"}
-{"UserId":5,"FirstName":"Shani","LastName":"Strauss","Email":"huuu@gmail.com","Password":"11111"}
-{"UserId":6,"FirstName":"Shani","LastName":"Strauss","Email":"huuu@gmail.com","Password":"mmmmm"}
-{"UserId":7,"FirstName":"Shani","LastName":"Strauss","Email":"huuu@gmail.com","Password":"mmmmm"}
-{"UserId":8,"FirstName":"erw","LastName":"ar","Email":"huuu@gmail.com","Password":"rrrrrrrrrrr"}
-{"UserId":9,"FirstName":"Shani","LastName":"Strauss","Email":"Shani@gmail.com","Password":"1234"}
-{"UserId":10,"FirstName":"w","LastName":"w","Email":"a@gmail.com","Password":"111"}
-{"UserId":11,"FirstName":"w","LastName":"w","Email":"a@gmail.com","Password":"111"}
-{"UserId":12,"FirstName":"c","LastName":"d","Email":"a@gmail.com","Password":"111"}
-{"UserId":13,"FirstName":"c","LastName":"d","Email":"a@gmail.com","Password":"111"}
-{"UserId":14,"FirstName":"c","LastName":"d","Email":"a@gmail.com","Password":"111"}
diff --git a/Services/IUserService.cs b/Services/IUserService.cs
index ce1e0a6..ffb1ce1 100644
--- a/Services/IUserService.cs
+++ b/Services/IUserService.cs
@@ -9,7 +9,6 @@ public interface IUserService
Task addUser(User user);
int evalutePassword(string password);
Task GetUserByEmailAndPassword(User userLogin);
- //Task getUserById(int id);
Task updateUser(int id, User userToUpdate);
}
}
\ No newline at end of file
diff --git a/Services/UserService.cs b/Services/UserService.cs
index a42afef..c3573cf 100644
--- a/Services/UserService.cs
+++ b/Services/UserService.cs
@@ -1,6 +1,4 @@
using DTO;
-//using Entities;
-
using Repositories;
using System.Data;
using Zxcvbn;
@@ -10,16 +8,12 @@ public class UserService : IUserService
{
private IUserRepository _userRepository;
+
public UserService(IUserRepository userRepository)
{
_userRepository = userRepository;
}
- //public async Task getUserById(int id)
- //{
- // return await _userRepository.getUserById(id);
- //}
-
public async Task addUser(User user)
{
@@ -27,20 +21,20 @@ public async Task addUser(User user)
return null;
return await _userRepository.addUser(user);
}
+
public async Task updateUser(int id, User userToUpdate)
{
if (evalutePassword(userToUpdate.Password) < 2)
return null;
return await _userRepository.updateUser(id, userToUpdate);
}
+
public int evalutePassword(string password)
{
var result = Zxcvbn.Core.EvaluatePassword(password);
return (int)result.Score;
}
-
-
public Task GetUserByEmailAndPassword(User userLogin)
{
return _userRepository.GetUserByEmailAndPassword(userLogin);