This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public class PersonalDetails | |
| { | |
| public int Id { get; set; } | |
| public string Title { get; set; } | |
| public string Name { get; set; } | |
| public string City { get; set; } | |
| public int LoyaltyPoints { get; set; } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | using CustomerManagement.Models; | |
| using Microsoft.EntityFrameworkCore; | |
| namespace CustomerManagement.Data | |
| { | |
| public class CustomerDbContext : DbContext | |
| { | |
| public CustomerDbContext(DbContextOptions<CustomerDbContext> options) : base(options) | |
| { } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | namespace CustomerManagement.RequestModels.CommandRequests | |
| { | |
| public class SaveCustomerRequestModel | |
| { | |
| public string Title { get; set; } | |
| public string Name { get; set; } | |
| public string City { get; set; } | |
| public int LoyaltyPoints { get; set; } | |
| } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | namespace CustomerManagement.Contracts.CommandHandlers | |
| { | |
| public interface ISaveCustomerCommandHandler | |
| { | |
| Task<int> SaveAsync(SaveCustomerRequestModel saveCustomerRequestModel); | |
| } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | using CustomerManagement.Contracts.CommandHandlers; | |
| using CustomerManagement.Data; | |
| using CustomerManagement.Models; | |
| using CustomerManagement.RequestModels.CommandRequests; | |
| using System.Threading.Tasks; | |
| namespace CustomerManagement.Handlers.CommandHandlers | |
| { | |
| public class SaveCustomerCommandHandler : ISaveCustomerCommandHandler | |
| { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | namespace CustomerManagement.Controllers | |
| { | |
| [Route("api/[controller]")] | |
| [ApiController] | |
| public class CustomerController : ControllerBase | |
| { | |
| private readonly ISaveCustomerCommandHandler saveCustomerCommandHandler; | |
| public CustomerController(ISaveCustomerCommandHandler saveCustomerCommandHandler) | |
| { | |
| this.saveCustomerCommandHandler = saveCustomerCommandHandler; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | namespace CustomerManagement.ResponseModels.QueryResponses | |
| { | |
| public class AllCustomerQueryResponseModel | |
| { | |
| public int Id { get; set; } | |
| public string Title { get; set; } | |
| public string Name { get; set; } | |
| public string City { get; set; } | |
| public int LoyaltyPoints { get; set; } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | namespace CustomerManagement.Contracts.QueryHandlers | |
| { | |
| public interface IAllCustomerQueryHandler | |
| { | |
| Task<List<AllCustomerQueryResponseModel>> GetAllAsync(); | |
| } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | namespace CustomerManagement.Handlers.QueryHandler | |
| { | |
| public class AllCustomerQueryHandler : IAllCustomerQueryHandler | |
| { | |
| private readonly CustomerDbContext context; | |
| public AllCustomerQueryHandler(CustomerDbContext context) | |
| { | |
| this.context = context; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | [HttpGet] | |
| [Route("get-all")] | |
| public async Task<List<AllCustomerQueryResponseModel>> GetAllCustomerAsync() | |
| { | |
| try | |
| { | |
| return await this.allCustomerQueryHandler.GetAllAsync(); | |
| } | |
| catch | |
| { | 
OlderNewer