Skip to content

Commit

Permalink
add update some files
Browse files Browse the repository at this point in the history
  • Loading branch information
Tohirjon-Odilov committed Mar 3, 2024
1 parent 70d0383 commit e5bb1b7
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 55 deletions.
4 changes: 2 additions & 2 deletions Exam.StockManagement.API/Controllers/CategoryController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ namespace Exam.StockManagement.API.Controllers
public class CategoryController : ControllerBase
{
[HttpPost]
public async Task<IActionResult> Create(int id)
public async Task<IActionResult> Create(string name)
{
return Ok("Salom");
return Ok();
}

[HttpGet]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Exam.StockManagement.Application.Abstractions.IServices;
using Exam.StockManagement.Domain.Entities.DTOs;
using Exam.StockManagement.Domain.Entities.DTOs.Auth;
using Exam.StockManagement.Domain.Exceptions;
using Microsoft.AspNetCore.Mvc;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Exam.StockManagement.Domain.Entities.DTOs;
using Exam.StockManagement.Domain.Entities.DTOs.Auth;
using Exam.StockManagement.Domain.Entities.Models;

namespace Exam.StockManagement.Application.Abstractions.IServices
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Exam.StockManagement.Domain.Entities.Models;

namespace Exam.StockManagement.Application.Abstractions.IServices
{
public interface ICategoryService
{
public Task<string> Create();
public Task<List<Category>> GetAll();
public Task<string> Update();
public Task<string> Delete();
}
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
using Exam.StockManagement.Domain.Entities.DTOs;
using Exam.StockManagement.Domain.Entities.Models;
using Exam.StockManagement.Domain.Entities.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Exam.StockManagement.Application.Abstractions.IServices
{
public interface IProductService
{
public Task<Product> Create(ProductDTO userDTO);
public Task<Product> GetByName(string name);
public Task<Product> GetById(int Id);
public Task<Product> GetByEmail(string email);
public Task<Product> GetByLogin(string email);
public Task<IEnumerable<ProductViewModel>> GetAll();
public Task<bool> Delete(Expression<Func<Product, bool>> expression);
public Task<Product> Update(int Id, ProductDTO userDTO);
public Task<string> Create();
public Task<List<Category>> GetAll();
public Task<string> Update();
public Task<string> Delete();
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Exam.StockManagement.Domain.Entities.Models;

namespace Exam.StockManagement.Application.Abstractions.IServices
{
public interface IStatsService
{
public Task<string> Create();
public Task<List<Category>> GetAll();
public Task<string> Update();
public Task<string> Delete();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Exam.StockManagement.Domain.Entities.DTOs;
using Exam.StockManagement.Domain.Entities.DTOs.Auth;
using Exam.StockManagement.Domain.Entities.Models;
using Exam.StockManagement.Domain.Entities.ViewModels;
using System.Linq.Expressions;
Expand All @@ -8,10 +9,7 @@ namespace Exam.StockManagement.Application.Abstractions.IServices
public interface IUserService
{
public Task<User> Create(RequestSignUp signUp);
public Task<User> GetByName(string name);
public Task<User> GetById(int Id);
public Task<User> GetByEmail(string email);
public Task<User> GetByLogin(string email);
public Task<IEnumerable<UserViewModel>> GetAll();
public Task<bool> Delete(Expression<Func<User, bool>> expression);
public Task<User> Update(int Id, UserDTO userDTO);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Exam.StockManagement.Application.Abstractions.IServices;
using Exam.StockManagement.Domain.Entities.DTOs;
using Exam.StockManagement.Domain.Entities.DTOs.Auth;
using Exam.StockManagement.Domain.Entities.Models;
using Exam.StockManagement.Domain.Exceptions;
using Microsoft.Extensions.Configuration;
Expand All @@ -24,7 +24,7 @@ public AuthService(IConfiguration conf, IUserService userService)

public async Task<string> CorrectEmail(RegisterLogin user)
{
var result = await _userService.GetByLogin(user.Email);
var result = await _userService.GetByEmail(user.Email);
if (result.Code == user.Code)
{
return "Login successfully!";
Expand Down Expand Up @@ -53,7 +53,7 @@ public async Task<ResponseLogin> GenerateToken(CheckEmail user, string path)

if (await UserExist(login))
{
var result = await _userService.GetByLogin(user.Email);
var result = await _userService.GetByEmail(user.Email);

List<Claim> claims = new List<Claim>()
{
Expand Down Expand Up @@ -111,7 +111,7 @@ public async Task<bool> UserExist(RequestLogin user)
throw new NotFoundException();
}

var result = await _userService.GetByLogin(user.Email);
var result = await _userService.GetByEmail(user.Email);

if (result != null)
{
Expand Down
14 changes: 1 addition & 13 deletions Exam.StockManagement.Application/Services/UserService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Exam.StockManagement.Application.Abstractions.IRepository;
using Exam.StockManagement.Application.Abstractions.IServices;
using Exam.StockManagement.Domain.Entities.DTOs;
using Exam.StockManagement.Domain.Entities.DTOs.Auth;
using Exam.StockManagement.Domain.Entities.Models;
using Exam.StockManagement.Domain.Entities.ViewModels;
using Exam.StockManagement.Domain.Exceptions;
Expand All @@ -19,7 +20,6 @@ public UserService(IUserRepository userRepository)

public async Task<User> Create(RequestSignUp requestSignUp)
{
//User? hasLogin = await _userRepository.GetByAny(x => x.Login == requestSignUp.Email);
var hasEmail = await _userRepository.GetByAny(x => x.Email == requestSignUp.Email);

if (requestSignUp.Password != requestSignUp.ConfirmPassword)
Expand Down Expand Up @@ -86,18 +86,6 @@ public async Task<User> GetById(int Id)
return result;
}

public async Task<User> GetByLogin(string email)
{
var result = await _userRepository.GetByAny(y => y.Email == email);
return result;
}

public async Task<User> GetByName(string name)
{
var result = await _userRepository.GetByAny(d => d.Name == name);
return result;
}

public async Task<User> Update(int Id, UserDTO userDTO)
{
var res = await _userRepository.GetByAny(x => x.Id == Id);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Exam.StockManagement.Domain.Entities.DTOs
namespace Exam.StockManagement.Domain.Entities.DTOs.Auth
{
public class CheckEmail
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Exam.StockManagement.Domain.Entities.DTOs
namespace Exam.StockManagement.Domain.Entities.DTOs.Auth
{
public class RegisterLogin
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Exam.StockManagement.Domain.Entities.DTOs
namespace Exam.StockManagement.Domain.Entities.DTOs.Auth
{
public class RequestLogin
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Exam.StockManagement.Domain.Entities.DTOs
namespace Exam.StockManagement.Domain.Entities.DTOs.Auth
{
public class RequestSignUp
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Exam.StockManagement.Domain.Entities.DTOs
namespace Exam.StockManagement.Domain.Entities.DTOs.Auth
{
public class ResponseLogin
{
Expand Down

0 comments on commit e5bb1b7

Please sign in to comment.