Browse Source

SP_10062024_CodeFixed

main
Soumen Pal 7 months ago
parent
commit
bbb10b436a
20 changed files with 2450 additions and 166 deletions
  1. +1
    -1
      angular/src/app/book-issue/book-issue.component.ts
  2. +2
    -2
      angular/src/app/customer/customer.component.ts
  3. +3
    -3
      angular/src/app/proxy/book-issued/book-issue.service.ts
  4. +4
    -4
      angular/src/app/proxy/book-issued/models.ts
  5. +3
    -3
      angular/src/app/proxy/customers/customer.service.ts
  6. +5
    -5
      angular/src/app/proxy/customers/models.ts
  7. +70
    -70
      angular/src/app/proxy/generate-proxy.json
  8. +6
    -6
      aspnet-core/src/Acme.BookStore.Application.Contracts/BookIssued/BookIssueDto.cs
  9. +4
    -4
      aspnet-core/src/Acme.BookStore.Application.Contracts/Customers/CustomerDto.cs
  10. +2
    -2
      aspnet-core/src/Acme.BookStore.Application/Customers/CustomerAppService.cs
  11. +8
    -8
      aspnet-core/src/Acme.BookStore.Domain/BookIssued/BookIssue.cs
  12. +4
    -4
      aspnet-core/src/Acme.BookStore.Domain/BookIssued/BookIssueManager.cs
  13. +10
    -10
      aspnet-core/src/Acme.BookStore.Domain/Customers/Customer.cs
  14. +10
    -10
      aspnet-core/src/Acme.BookStore.Domain/Customers/CustomerManager.cs
  15. +13
    -13
      aspnet-core/src/Acme.BookStore.EntityFrameworkCore/BookIssued/EfCoreBookIssueRepository.cs
  16. +1
    -1
      aspnet-core/src/Acme.BookStore.EntityFrameworkCore/Customers/EfCoreCustomerRepository.cs
  17. +3
    -3
      aspnet-core/src/Acme.BookStore.EntityFrameworkCore/EntityFrameworkCore/BookStoreDbContext.cs
  18. +2206
    -0
      aspnet-core/src/Acme.BookStore.EntityFrameworkCore/Migrations/20240610172008_Table_Naming_Convension.Designer.cs
  19. +78
    -0
      aspnet-core/src/Acme.BookStore.EntityFrameworkCore/Migrations/20240610172008_Table_Naming_Convension.cs
  20. +17
    -17
      aspnet-core/src/Acme.BookStore.EntityFrameworkCore/Migrations/BookStoreDbContextModelSnapshot.cs

+ 1
- 1
angular/src/app/book-issue/book-issue.component.ts View File

@ -72,7 +72,7 @@ export class BookIssueComponent implements OnInit {
}); });
} }
delete(bookIssueId: number) {
delete(bookIssueId: string) {
this.confirmation.warn('::AreYouSureToUnIssue', '::AreYouSure').subscribe((status) => { this.confirmation.warn('::AreYouSureToUnIssue', '::AreYouSure').subscribe((status) => {
if (status === Confirmation.Status.confirm) { if (status === Confirmation.Status.confirm) {
this.bookIssuedService.delete(bookIssueId).subscribe(() => this.list.get()); this.bookIssuedService.delete(bookIssueId).subscribe(() => this.list.get());


+ 2
- 2
angular/src/app/customer/customer.component.ts View File

@ -35,7 +35,7 @@ export class CustomerComponent implements OnInit {
this.buildForm(); this.buildForm();
this.isModalOpen = true; this.isModalOpen = true;
} }
editCustomer(id: number) {
editCustomer(id: string) {
this.customerService.get(id).subscribe((customer) => { this.customerService.get(id).subscribe((customer) => {
debugger; debugger;
this.selectedcustomer = customer; this.selectedcustomer = customer;
@ -82,7 +82,7 @@ else{
} }
delete(id: number) {
delete(id: string) {
this.confirmation.warn('::AreYouSureToDelete', '::AreYouSure').subscribe((status) => { this.confirmation.warn('::AreYouSureToDelete', '::AreYouSure').subscribe((status) => {
if (status === Confirmation.Status.confirm) { if (status === Confirmation.Status.confirm) {
this.customerService.delete(id).subscribe(() => this.list.get()); this.customerService.delete(id).subscribe(() => this.list.get());


+ 3
- 3
angular/src/app/proxy/book-issued/book-issue.service.ts View File

@ -19,7 +19,7 @@ export class BookIssueService {
{ apiName: this.apiName,...config }); { apiName: this.apiName,...config });
delete = (id: number, config?: Partial<Rest.Config>) =>
delete = (id: string, config?: Partial<Rest.Config>) =>
this.restService.request<any, void>({ this.restService.request<any, void>({
method: 'DELETE', method: 'DELETE',
url: `/api/app/book-issue/${id}`, url: `/api/app/book-issue/${id}`,
@ -27,7 +27,7 @@ export class BookIssueService {
{ apiName: this.apiName,...config }); { apiName: this.apiName,...config });
get = (id: number, config?: Partial<Rest.Config>) =>
get = (id: string, config?: Partial<Rest.Config>) =>
this.restService.request<any, BookIssueDto>({ this.restService.request<any, BookIssueDto>({
method: 'GET', method: 'GET',
url: `/api/app/book-issue/${id}`, url: `/api/app/book-issue/${id}`,
@ -43,7 +43,7 @@ export class BookIssueService {
{ apiName: this.apiName,...config }); { apiName: this.apiName,...config });
update = (id: number, input: BookIssueDto, config?: Partial<Rest.Config>) =>
update = (id: string, input: BookIssueDto, config?: Partial<Rest.Config>) =>
this.restService.request<any, void>({ this.restService.request<any, void>({
method: 'PUT', method: 'PUT',
url: `/api/app/book-issue/${id}`, url: `/api/app/book-issue/${id}`,


+ 4
- 4
angular/src/app/proxy/book-issued/models.ts View File

@ -1,12 +1,12 @@
import type { EntityDto } from '@abp/ng.core'; import type { EntityDto } from '@abp/ng.core';
export interface BookIssueDto extends EntityDto<number> {
bookId?: string;
customerId: number;
export interface BookIssueDto extends EntityDto<string> {
bookId: string;
customerId: string;
} }
export interface BookIssueListDto { export interface BookIssueListDto {
bookIssueId: number;
bookIssueId?: string;
bookName?: string; bookName?: string;
customerName?: string; customerName?: string;
issueDate?: string; issueDate?: string;


+ 3
- 3
angular/src/app/proxy/customers/customer.service.ts View File

@ -19,7 +19,7 @@ export class CustomerService {
{ apiName: this.apiName,...config }); { apiName: this.apiName,...config });
delete = (id: number, config?: Partial<Rest.Config>) =>
delete = (id: string, config?: Partial<Rest.Config>) =>
this.restService.request<any, void>({ this.restService.request<any, void>({
method: 'DELETE', method: 'DELETE',
url: `/api/app/customer/${id}`, url: `/api/app/customer/${id}`,
@ -27,7 +27,7 @@ export class CustomerService {
{ apiName: this.apiName,...config }); { apiName: this.apiName,...config });
get = (id: number, config?: Partial<Rest.Config>) =>
get = (id: string, config?: Partial<Rest.Config>) =>
this.restService.request<any, CustomerDto>({ this.restService.request<any, CustomerDto>({
method: 'GET', method: 'GET',
url: `/api/app/customer/${id}`, url: `/api/app/customer/${id}`,
@ -51,7 +51,7 @@ export class CustomerService {
{ apiName: this.apiName,...config }); { apiName: this.apiName,...config });
update = (id: number, input: CustomerDto, config?: Partial<Rest.Config>) =>
update = (id: string, input: CustomerDto, config?: Partial<Rest.Config>) =>
this.restService.request<any, void>({ this.restService.request<any, void>({
method: 'PUT', method: 'PUT',
url: `/api/app/customer/${id}`, url: `/api/app/customer/${id}`,


+ 5
- 5
angular/src/app/proxy/customers/models.ts View File

@ -1,8 +1,8 @@
import type { EntityDto } from '@abp/ng.core'; import type { EntityDto } from '@abp/ng.core';
export interface CustomerDto extends EntityDto<number> {
firstName?: string;
lastName?: string;
phone?: string;
address?: string;
export interface CustomerDto extends EntityDto<string> {
firstName: string;
lastName: string;
phone: string;
address: string;
} }

+ 70
- 70
angular/src/app/proxy/generate-proxy.json View File

@ -1242,9 +1242,9 @@
"parametersOnMethod": [ "parametersOnMethod": [
{ {
"name": "id", "name": "id",
"typeAsString": "System.Int32, System.Private.CoreLib",
"type": "System.Int32",
"typeSimple": "number",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false, "isOptional": false,
"defaultValue": null "defaultValue": null
} }
@ -1284,9 +1284,9 @@
"parametersOnMethod": [ "parametersOnMethod": [
{ {
"name": "id", "name": "id",
"typeAsString": "System.Int32, System.Private.CoreLib",
"type": "System.Int32",
"typeSimple": "number",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false, "isOptional": false,
"defaultValue": null "defaultValue": null
}, },
@ -1309,9 +1309,9 @@
"parametersOnMethod": [ "parametersOnMethod": [
{ {
"name": "id", "name": "id",
"typeAsString": "System.Int32, System.Private.CoreLib",
"type": "System.Int32",
"typeSimple": "number",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false, "isOptional": false,
"defaultValue": null "defaultValue": null
} }
@ -1334,9 +1334,9 @@
"parametersOnMethod": [ "parametersOnMethod": [
{ {
"name": "id", "name": "id",
"typeAsString": "System.Int32, System.Private.CoreLib",
"type": "System.Int32",
"typeSimple": "number",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false, "isOptional": false,
"defaultValue": null "defaultValue": null
} }
@ -1346,8 +1346,8 @@
"nameOnMethod": "id", "nameOnMethod": "id",
"name": "id", "name": "id",
"jsonName": null, "jsonName": null,
"type": "System.Int32",
"typeSimple": "number",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false, "isOptional": false,
"defaultValue": null, "defaultValue": null,
"constraintTypes": [], "constraintTypes": [],
@ -1423,9 +1423,9 @@
"parametersOnMethod": [ "parametersOnMethod": [
{ {
"name": "id", "name": "id",
"typeAsString": "System.Int32, System.Private.CoreLib",
"type": "System.Int32",
"typeSimple": "number",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false, "isOptional": false,
"defaultValue": null "defaultValue": null
}, },
@ -1443,8 +1443,8 @@
"nameOnMethod": "id", "nameOnMethod": "id",
"name": "id", "name": "id",
"jsonName": null, "jsonName": null,
"type": "System.Int32",
"typeSimple": "number",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false, "isOptional": false,
"defaultValue": null, "defaultValue": null,
"constraintTypes": [], "constraintTypes": [],
@ -1480,9 +1480,9 @@
"parametersOnMethod": [ "parametersOnMethod": [
{ {
"name": "id", "name": "id",
"typeAsString": "System.Int32, System.Private.CoreLib",
"type": "System.Int32",
"typeSimple": "number",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false, "isOptional": false,
"defaultValue": null "defaultValue": null
} }
@ -1492,8 +1492,8 @@
"nameOnMethod": "id", "nameOnMethod": "id",
"name": "id", "name": "id",
"jsonName": null, "jsonName": null,
"type": "System.Int32",
"typeSimple": "number",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false, "isOptional": false,
"defaultValue": null, "defaultValue": null,
"constraintTypes": [], "constraintTypes": [],
@ -1890,9 +1890,9 @@
"parametersOnMethod": [ "parametersOnMethod": [
{ {
"name": "id", "name": "id",
"typeAsString": "System.Int32, System.Private.CoreLib",
"type": "System.Int32",
"typeSimple": "number",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false, "isOptional": false,
"defaultValue": null "defaultValue": null
} }
@ -1932,9 +1932,9 @@
"parametersOnMethod": [ "parametersOnMethod": [
{ {
"name": "id", "name": "id",
"typeAsString": "System.Int32, System.Private.CoreLib",
"type": "System.Int32",
"typeSimple": "number",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false, "isOptional": false,
"defaultValue": null "defaultValue": null
}, },
@ -1957,9 +1957,9 @@
"parametersOnMethod": [ "parametersOnMethod": [
{ {
"name": "id", "name": "id",
"typeAsString": "System.Int32, System.Private.CoreLib",
"type": "System.Int32",
"typeSimple": "number",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false, "isOptional": false,
"defaultValue": null "defaultValue": null
} }
@ -1990,9 +1990,9 @@
"parametersOnMethod": [ "parametersOnMethod": [
{ {
"name": "id", "name": "id",
"typeAsString": "System.Int32, System.Private.CoreLib",
"type": "System.Int32",
"typeSimple": "number",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false, "isOptional": false,
"defaultValue": null "defaultValue": null
} }
@ -2002,8 +2002,8 @@
"nameOnMethod": "id", "nameOnMethod": "id",
"name": "id", "name": "id",
"jsonName": null, "jsonName": null,
"type": "System.Int32",
"typeSimple": "number",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false, "isOptional": false,
"defaultValue": null, "defaultValue": null,
"constraintTypes": [], "constraintTypes": [],
@ -2094,9 +2094,9 @@
"parametersOnMethod": [ "parametersOnMethod": [
{ {
"name": "id", "name": "id",
"typeAsString": "System.Int32, System.Private.CoreLib",
"type": "System.Int32",
"typeSimple": "number",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false, "isOptional": false,
"defaultValue": null "defaultValue": null
}, },
@ -2114,8 +2114,8 @@
"nameOnMethod": "id", "nameOnMethod": "id",
"name": "id", "name": "id",
"jsonName": null, "jsonName": null,
"type": "System.Int32",
"typeSimple": "number",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false, "isOptional": false,
"defaultValue": null, "defaultValue": null,
"constraintTypes": [], "constraintTypes": [],
@ -2151,9 +2151,9 @@
"parametersOnMethod": [ "parametersOnMethod": [
{ {
"name": "id", "name": "id",
"typeAsString": "System.Int32, System.Private.CoreLib",
"type": "System.Int32",
"typeSimple": "number",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false, "isOptional": false,
"defaultValue": null "defaultValue": null
} }
@ -2163,8 +2163,8 @@
"nameOnMethod": "id", "nameOnMethod": "id",
"name": "id", "name": "id",
"jsonName": null, "jsonName": null,
"type": "System.Int32",
"typeSimple": "number",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false, "isOptional": false,
"defaultValue": null, "defaultValue": null,
"constraintTypes": [], "constraintTypes": [],
@ -4947,18 +4947,18 @@
] ]
}, },
"Acme.BookStore.BookIssued.BookIssueDto": { "Acme.BookStore.BookIssued.BookIssueDto": {
"baseType": "Volo.Abp.Application.Dtos.EntityDto<System.Int32>",
"baseType": "Volo.Abp.Application.Dtos.EntityDto<System.Guid>",
"isEnum": false, "isEnum": false,
"enumNames": null, "enumNames": null,
"enumValues": null, "enumValues": null,
"genericArguments": null, "genericArguments": null,
"properties": [ "properties": [
{ {
"name": "bookId",
"name": "BookId",
"jsonName": null, "jsonName": null,
"type": "System.Guid", "type": "System.Guid",
"typeSimple": "string", "typeSimple": "string",
"isRequired": false,
"isRequired": true,
"minLength": null, "minLength": null,
"maxLength": null, "maxLength": null,
"minimum": null, "minimum": null,
@ -4966,11 +4966,11 @@
"regex": null "regex": null
}, },
{ {
"name": "customerId",
"name": "CustomerId",
"jsonName": null, "jsonName": null,
"type": "System.Int32",
"typeSimple": "number",
"isRequired": false,
"type": "System.Guid",
"typeSimple": "string",
"isRequired": true,
"minLength": null, "minLength": null,
"maxLength": null, "maxLength": null,
"minimum": null, "minimum": null,
@ -4987,10 +4987,10 @@
"genericArguments": null, "genericArguments": null,
"properties": [ "properties": [
{ {
"name": "bookIssueId",
"name": "BookIssueId",
"jsonName": null, "jsonName": null,
"type": "System.Int32",
"typeSimple": "number",
"type": "System.Guid",
"typeSimple": "string",
"isRequired": false, "isRequired": false,
"minLength": null, "minLength": null,
"maxLength": null, "maxLength": null,
@ -4999,7 +4999,7 @@
"regex": null "regex": null
}, },
{ {
"name": "bookName",
"name": "BookName",
"jsonName": null, "jsonName": null,
"type": "System.String", "type": "System.String",
"typeSimple": "string", "typeSimple": "string",
@ -5011,7 +5011,7 @@
"regex": null "regex": null
}, },
{ {
"name": "customerName",
"name": "CustomerName",
"jsonName": null, "jsonName": null,
"type": "System.String", "type": "System.String",
"typeSimple": "string", "typeSimple": "string",
@ -5023,7 +5023,7 @@
"regex": null "regex": null
}, },
{ {
"name": "issueDate",
"name": "IssueDate",
"jsonName": null, "jsonName": null,
"type": "System.DateTime", "type": "System.DateTime",
"typeSimple": "string", "typeSimple": "string",
@ -5179,18 +5179,18 @@
] ]
}, },
"Acme.BookStore.Customers.CustomerDto": { "Acme.BookStore.Customers.CustomerDto": {
"baseType": "Volo.Abp.Application.Dtos.EntityDto<System.Int32>",
"baseType": "Volo.Abp.Application.Dtos.EntityDto<System.Guid>",
"isEnum": false, "isEnum": false,
"enumNames": null, "enumNames": null,
"enumValues": null, "enumValues": null,
"genericArguments": null, "genericArguments": null,
"properties": [ "properties": [
{ {
"name": "firstName",
"name": "FirstName",
"jsonName": null, "jsonName": null,
"type": "System.String", "type": "System.String",
"typeSimple": "string", "typeSimple": "string",
"isRequired": false,
"isRequired": true,
"minLength": null, "minLength": null,
"maxLength": null, "maxLength": null,
"minimum": null, "minimum": null,
@ -5198,11 +5198,11 @@
"regex": null "regex": null
}, },
{ {
"name": "lastName",
"name": "LastName",
"jsonName": null, "jsonName": null,
"type": "System.String", "type": "System.String",
"typeSimple": "string", "typeSimple": "string",
"isRequired": false,
"isRequired": true,
"minLength": null, "minLength": null,
"maxLength": null, "maxLength": null,
"minimum": null, "minimum": null,
@ -5210,11 +5210,11 @@
"regex": null "regex": null
}, },
{ {
"name": "phone",
"name": "Phone",
"jsonName": null, "jsonName": null,
"type": "System.String", "type": "System.String",
"typeSimple": "string", "typeSimple": "string",
"isRequired": false,
"isRequired": true,
"minLength": null, "minLength": null,
"maxLength": null, "maxLength": null,
"minimum": null, "minimum": null,
@ -5222,11 +5222,11 @@
"regex": null "regex": null
}, },
{ {
"name": "address",
"name": "Address",
"jsonName": null, "jsonName": null,
"type": "System.String", "type": "System.String",
"typeSimple": "string", "typeSimple": "string",
"isRequired": false,
"isRequired": true,
"minLength": null, "minLength": null,
"maxLength": null, "maxLength": null,
"minimum": null, "minimum": null,


+ 6
- 6
aspnet-core/src/Acme.BookStore.Application.Contracts/BookIssued/BookIssueDto.cs View File

@ -9,17 +9,17 @@ namespace Acme.BookStore.BookIssued
public class BookIssueDto : EntityDto<Guid> public class BookIssueDto : EntityDto<Guid>
{ {
[Required] [Required]
public Guid bookId { get; set; }
public Guid BookId { get; set; }
[Required] [Required]
public Guid customerId { get; set; }
public Guid CustomerId { get; set; }
} }
public class BookIssueListDto public class BookIssueListDto
{ {
public Guid bookIssueId { get; set; }
public string bookName { get; set; }
public string customerName { get; set; }
public DateTime issueDate { get; set; }
public Guid BookIssueId { get; set; }
public string BookName { get; set; }
public string CustomerName { get; set; }
public DateTime IssueDate { get; set; }
} }
} }

+ 4
- 4
aspnet-core/src/Acme.BookStore.Application.Contracts/Customers/CustomerDto.cs View File

@ -9,12 +9,12 @@ namespace Acme.BookStore.Customers
public class CustomerDto : EntityDto<Guid> public class CustomerDto : EntityDto<Guid>
{ {
[Required] [Required]
public string firstName { get; set; }
public string FirstName { get; set; }
[Required] [Required]
public string lastName { get; set; }
public string LastName { get; set; }
[Required] [Required]
public string phone { get; set; }
public string Phone { get; set; }
[Required] [Required]
public string address { get; set; }
public string Address { get; set; }
} }
} }

+ 2
- 2
aspnet-core/src/Acme.BookStore.Application/Customers/CustomerAppService.cs View File

@ -67,9 +67,9 @@ namespace Acme.BookStore.Customers
{ {
var cus = await _customerRepository.GetAsync(id); var cus = await _customerRepository.GetAsync(id);
if (cus.phone == input.phone)
if (cus.Phone == input.Phone)
{ {
await _customerManager.ChangeNameAsync(cus, input.firstName,input.lastName);
await _customerManager.ChangeNameAsync(cus, input.FirstName,input.LastName);
} }
await _customerRepository.UpdateAsync(cus); await _customerRepository.UpdateAsync(cus);


+ 8
- 8
aspnet-core/src/Acme.BookStore.Domain/BookIssued/BookIssue.cs View File

@ -9,25 +9,25 @@ namespace Acme.BookStore.BookIssued
{ {
public class BookIssue : FullAuditedAggregateRoot<Guid> public class BookIssue : FullAuditedAggregateRoot<Guid>
{ {
public Guid bookId { get; set; }
public Guid customerId { get; set; }
public Guid BookId { get; set; }
public Guid CustomerId { get; set; }
private BookIssue() private BookIssue()
{ {
/* This constructor is for deserialization / ORM purpose */ /* This constructor is for deserialization / ORM purpose */
} }
internal BookIssue(Guid id, Guid bookId, Guid customerId) : base(id) internal BookIssue(Guid id, Guid bookId, Guid customerId) : base(id)
{ {
this.bookId = bookId;
this.customerId = customerId;
this.BookId = bookId;
this.CustomerId = customerId;
} }
} }
public class BookIssueList public class BookIssueList
{ {
public Guid bookIssueId { get; set; }
public string bookName { get; set; }
public string customerName { get; set; }
public DateTime issueDate { get; set; }
public Guid BookIssueId { get; set; }
public string BookName { get; set; }
public string CustomerName { get; set; }
public DateTime IssueDate { get; set; }
} }
} }

+ 4
- 4
aspnet-core/src/Acme.BookStore.Domain/BookIssued/BookIssueManager.cs View File

@ -20,15 +20,15 @@ namespace Acme.BookStore.BookIssued
public async Task<BookIssue> CreateAsync( public async Task<BookIssue> CreateAsync(
BookIssue bookissue) BookIssue bookissue)
{ {
var existingBookIssue = await _bookIssueRepository.FindBookIssueCustomer(bookissue.customerId,bookissue.bookId);
var existingBookIssue = await _bookIssueRepository.FindBookIssueCustomer(bookissue.CustomerId,bookissue.BookId);
if (existingBookIssue != null) if (existingBookIssue != null)
{ {
throw new BookIssueErrorException(existingBookIssue.customerName, existingBookIssue.bookName);
throw new BookIssueErrorException(existingBookIssue.CustomerName, existingBookIssue.BookName);
} }
return new BookIssue( return new BookIssue(
GuidGenerator.Create(), GuidGenerator.Create(),
bookissue.bookId,
bookissue.customerId
bookissue.BookId,
bookissue.CustomerId
); );
} }


+ 10
- 10
aspnet-core/src/Acme.BookStore.Domain/Customers/Customer.cs View File

@ -10,20 +10,20 @@ namespace Acme.BookStore.Customers
{ {
public class Customer : FullAuditedAggregateRoot<Guid> public class Customer : FullAuditedAggregateRoot<Guid>
{ {
public string firstName { get; set; }
public string lastName { get; set; }
public string phone { get; set; }
public string address { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Phone { get; set; }
public string Address { get; set; }
private Customer() private Customer()
{ {
/* This constructor is for deserialization / ORM purpose */ /* This constructor is for deserialization / ORM purpose */
} }
internal Customer(Guid id, string firstName, string lastName, string phone, string address) : base(id) internal Customer(Guid id, string firstName, string lastName, string phone, string address) : base(id)
{ {
this.firstName = firstName;
this.lastName = lastName;
this.phone = phone;
this.address = address;
this.FirstName = firstName;
this.LastName = lastName;
this.Phone = phone;
this.Address = address;
} }
internal Customer ChangeFirstName(string firstname) internal Customer ChangeFirstName(string firstname)
@ -39,7 +39,7 @@ namespace Acme.BookStore.Customers
nameof(firstName), nameof(firstName),
maxLength: CustomerConsts.MaxNameLength maxLength: CustomerConsts.MaxNameLength
); );
this.firstName = firstName;
this.FirstName = firstName;
} }
internal Customer ChangeLastName(string lastname) internal Customer ChangeLastName(string lastname)
{ {
@ -54,7 +54,7 @@ namespace Acme.BookStore.Customers
nameof(lastname), nameof(lastname),
maxLength: CustomerConsts.MaxNameLength maxLength: CustomerConsts.MaxNameLength
); );
this.lastName = lastname;
this.LastName = lastname;
} }
} }
} }

+ 10
- 10
aspnet-core/src/Acme.BookStore.Domain/Customers/CustomerManager.cs View File

@ -22,20 +22,20 @@ namespace Acme.BookStore.Customers
public async Task<Customer> CreateAsync( public async Task<Customer> CreateAsync(
Customer customer) Customer customer)
{ {
Check.NotNullOrWhiteSpace(customer.firstName, nameof(customer.firstName));
Check.NotNullOrWhiteSpace(customer.lastName, nameof(customer.lastName));
Check.NotNullOrWhiteSpace(customer.FirstName, nameof(customer.FirstName));
Check.NotNullOrWhiteSpace(customer.LastName, nameof(customer.LastName));
var existingAuthor = await _customerRepository.FindByPhoneAsync(customer.phone);
var existingAuthor = await _customerRepository.FindByPhoneAsync(customer.Phone);
if (existingAuthor != null) if (existingAuthor != null)
{ {
throw new CustomerErrorException(customer.phone);
throw new CustomerErrorException(customer.Phone);
} }
return new Customer( return new Customer(
GuidGenerator.Create(), GuidGenerator.Create(),
customer.firstName,
customer.lastName,
customer.phone,
customer.address
customer.FirstName,
customer.LastName,
customer.Phone,
customer.Address
); );
} }
@ -44,8 +44,8 @@ namespace Acme.BookStore.Customers
string firstName,string lastName) string firstName,string lastName)
{ {
Check.NotNull(customer, nameof(customer)); Check.NotNull(customer, nameof(customer));
Check.NotNullOrWhiteSpace(customer.firstName, nameof(customer.firstName));
Check.NotNullOrWhiteSpace(customer.lastName, nameof(customer.lastName));
Check.NotNullOrWhiteSpace(customer.FirstName, nameof(customer.FirstName));
Check.NotNullOrWhiteSpace(customer.LastName, nameof(customer.LastName));
customer.ChangeFirstName(firstName); customer.ChangeFirstName(firstName);
customer.ChangeLastName(lastName); customer.ChangeLastName(lastName);


+ 13
- 13
aspnet-core/src/Acme.BookStore.EntityFrameworkCore/BookIssued/EfCoreBookIssueRepository.cs View File

@ -36,15 +36,15 @@ namespace Acme.BookStore.BookIssued
List<BookIssueList> item = ( List<BookIssueList> item = (
from bi in dbContext.bookIssues from bi in dbContext.bookIssues
join cu in dbContext.Customers on bi.customerId equals cu.Id
join bk in dbContext.Books on bi.bookId equals bk.Id
where (bi.customerId == customerId && bi.bookId == bookId && bi.IsDeleted == false)
join cu in dbContext.Customers on bi.CustomerId equals cu.Id
join bk in dbContext.Books on bi.BookId equals bk.Id
where (bi.CustomerId == customerId && bi.BookId == bookId && bi.IsDeleted == false)
select new BookIssueList select new BookIssueList
{ {
bookIssueId = bi.Id,
bookName = bk.Name,
customerName = cu.firstName + " " + cu.lastName,
issueDate = bi.CreationTime
BookIssueId = bi.Id,
BookName = bk.Name,
CustomerName = cu.FirstName + " " + cu.LastName,
IssueDate = bi.CreationTime
}).ToList(); }).ToList();
return item == null? null : item.FirstOrDefault(); return item == null? null : item.FirstOrDefault();
@ -69,14 +69,14 @@ namespace Acme.BookStore.BookIssued
List<BookIssueList> item = ( List<BookIssueList> item = (
from bi in dbContext.bookIssues from bi in dbContext.bookIssues
join cu in dbContext.Customers on bi.customerId equals cu.Id
join bk in dbContext.Books on bi.bookId equals bk.Id
join cu in dbContext.Customers on bi.CustomerId equals cu.Id
join bk in dbContext.Books on bi.BookId equals bk.Id
select new BookIssueList select new BookIssueList
{ {
bookIssueId = bi.Id,
bookName = bk.Name,
customerName = cu.firstName + " " + cu.lastName,
issueDate = bi.CreationTime
BookIssueId = bi.Id,
BookName = bk.Name,
CustomerName = cu.FirstName + " " + cu.LastName,
IssueDate = bi.CreationTime
}).ToList(); }).ToList();
return item; return item;


+ 1
- 1
aspnet-core/src/Acme.BookStore.EntityFrameworkCore/Customers/EfCoreCustomerRepository.cs View File

@ -23,7 +23,7 @@ namespace Acme.BookStore.Customers
public async Task<Customer> FindByPhoneAsync(string phone) public async Task<Customer> FindByPhoneAsync(string phone)
{ {
var dbSet = await GetDbSetAsync(); var dbSet = await GetDbSetAsync();
return await dbSet.FirstOrDefaultAsync(cust => cust.phone == phone);
return await dbSet.FirstOrDefaultAsync(cust => cust.Phone == phone);
} }


+ 3
- 3
aspnet-core/src/Acme.BookStore.EntityFrameworkCore/EntityFrameworkCore/BookStoreDbContext.cs View File

@ -116,15 +116,15 @@ public class BookStoreDbContext :
b.ConfigureByConvention(); b.ConfigureByConvention();
b.Property(x => x.firstName)
b.Property(x => x.FirstName)
.IsRequired() .IsRequired()
.HasMaxLength(CustomerConsts.MaxNameLength); .HasMaxLength(CustomerConsts.MaxNameLength);
b.Property(x => x.lastName)
b.Property(x => x.LastName)
.IsRequired() .IsRequired()
.HasMaxLength(CustomerConsts.MaxNameLength); .HasMaxLength(CustomerConsts.MaxNameLength);
b.Property(x => x.phone)
b.Property(x => x.Phone)
.IsRequired() .IsRequired()
.HasMaxLength(CustomerConsts.MaxPhoneLength); .HasMaxLength(CustomerConsts.MaxPhoneLength);
}); });


+ 2206
- 0
aspnet-core/src/Acme.BookStore.EntityFrameworkCore/Migrations/20240610172008_Table_Naming_Convension.Designer.cs
File diff suppressed because it is too large
View File


+ 78
- 0
aspnet-core/src/Acme.BookStore.EntityFrameworkCore/Migrations/20240610172008_Table_Naming_Convension.cs View File

@ -0,0 +1,78 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Acme.BookStore.Migrations
{
/// <inheritdoc />
public partial class Table_Naming_Convension : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "phone",
table: "AppCustomers",
newName: "Phone");
migrationBuilder.RenameColumn(
name: "lastName",
table: "AppCustomers",
newName: "LastName");
migrationBuilder.RenameColumn(
name: "firstName",
table: "AppCustomers",
newName: "FirstName");
migrationBuilder.RenameColumn(
name: "address",
table: "AppCustomers",
newName: "Address");
migrationBuilder.RenameColumn(
name: "customerId",
table: "AppBookIssued",
newName: "CustomerId");
migrationBuilder.RenameColumn(
name: "bookId",
table: "AppBookIssued",
newName: "BookId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "Phone",
table: "AppCustomers",
newName: "phone");
migrationBuilder.RenameColumn(
name: "LastName",
table: "AppCustomers",
newName: "lastName");
migrationBuilder.RenameColumn(
name: "FirstName",
table: "AppCustomers",
newName: "firstName");
migrationBuilder.RenameColumn(
name: "Address",
table: "AppCustomers",
newName: "address");
migrationBuilder.RenameColumn(
name: "CustomerId",
table: "AppBookIssued",
newName: "customerId");
migrationBuilder.RenameColumn(
name: "BookId",
table: "AppBookIssued",
newName: "bookId");
}
}
}

+ 17
- 17
aspnet-core/src/Acme.BookStore.EntityFrameworkCore/Migrations/BookStoreDbContextModelSnapshot.cs View File

@ -95,6 +95,9 @@ namespace Acme.BookStore.Migrations
b.Property<Guid>("Id") b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<Guid>("BookId")
.HasColumnType("uniqueidentifier");
b.Property<string>("ConcurrencyStamp") b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken() .IsConcurrencyToken()
.IsRequired() .IsRequired()
@ -110,6 +113,9 @@ namespace Acme.BookStore.Migrations
.HasColumnType("uniqueidentifier") .HasColumnType("uniqueidentifier")
.HasColumnName("CreatorId"); .HasColumnName("CreatorId");
b.Property<Guid>("CustomerId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("DeleterId") b.Property<Guid?>("DeleterId")
.HasColumnType("uniqueidentifier") .HasColumnType("uniqueidentifier")
.HasColumnName("DeleterId"); .HasColumnName("DeleterId");
@ -137,12 +143,6 @@ namespace Acme.BookStore.Migrations
.HasColumnType("uniqueidentifier") .HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId"); .HasColumnName("LastModifierId");
b.Property<Guid>("bookId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("customerId")
.HasColumnType("uniqueidentifier");
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("AppBookIssued", (string)null); b.ToTable("AppBookIssued", (string)null);
@ -205,6 +205,10 @@ namespace Acme.BookStore.Migrations
b.Property<Guid>("Id") b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<string>("Address")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ConcurrencyStamp") b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken() .IsConcurrencyToken()
.IsRequired() .IsRequired()
@ -233,6 +237,11 @@ namespace Acme.BookStore.Migrations
.HasColumnType("nvarchar(max)") .HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties"); .HasColumnName("ExtraProperties");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<bool>("IsDeleted") b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("bit") .HasColumnType("bit")
@ -247,21 +256,12 @@ namespace Acme.BookStore.Migrations
.HasColumnType("uniqueidentifier") .HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId"); .HasColumnName("LastModifierId");
b.Property<string>("address")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("firstName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<string>("lastName")
b.Property<string>("LastName")
.IsRequired() .IsRequired()
.HasMaxLength(100) .HasMaxLength(100)
.HasColumnType("nvarchar(100)"); .HasColumnType("nvarchar(100)");
b.Property<string>("phone")
b.Property<string>("Phone")
.IsRequired() .IsRequired()
.HasMaxLength(14) .HasMaxLength(14)
.HasColumnType("nvarchar(14)"); .HasColumnType("nvarchar(14)");


Loading…
Cancel
Save