Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #23 from pytas0811/Dev
Browse files Browse the repository at this point in the history
UpdateEntity5
  • Loading branch information
k-nero authored Sep 22, 2023
2 parents 0be1ca0 + 9f42d83 commit b8c0370
Show file tree
Hide file tree
Showing 26 changed files with 592 additions and 547 deletions.
6 changes: 3 additions & 3 deletions src/Application/Buildings/Queries/BuildingViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace SWD_Laundry_Backend.Application.Buildings.Queries;
public class BuildingViewModel : IMapFrom<Building>
{
public string Name { get; set; }
public string Address { get; set; }
public string Description { get; set; }
public string? Name { get; set; }
public string? Address { get; set; }
public string? Description { get; set; }
}
2 changes: 2 additions & 0 deletions src/Application/Common/Interfaces/IApplicationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public interface IApplicationDbContext
DbSet<TodoList> TodoLists { get; }

DbSet<TodoItem> TodoItems { get; }

//DbSet<Customer> Customers { get; }
//DbSet<Building> Buildings { get; }
//DbSet<ApplicationUser> ApplicationUsers { get; }
Expand All @@ -21,6 +22,7 @@ public interface IApplicationDbContext
//DbSet<Transaction> Transactions { get; }
//DbSet<Wallet> Wallets { get; }


DbSet<T> Get<T>() where T : BaseAuditableEntity;

Task<int> SaveChangesAsync(CancellationToken cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
namespace SWD_Laundry_Backend.Application.PaymentMethods.Commands.CreatePaymentMethod;
public class CreatePaymentMethodCommand : IRequest<int>
{
public string Name { get; set; }
public string Description { get; set; }
public string? Name { get; set; }
public string? Description { get; set; }
}

public class CreatePaymentMethodCommandHandler : IRequestHandler<CreatePaymentMethodCommand, int>
Expand Down
2 changes: 1 addition & 1 deletion src/Application/PaymentMethods/Queries/PaymentMethodDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
namespace SWD_Laundry_Backend.Application.PaymentMethods.Queries;
public class PaymentMethodDto : IMapFrom<PaymentMethod>
{
public string Name { get; init; }
public string? Name { get; init; }
public string? Description { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ public GetTodoItemsWithPaginationQueryHandler(IApplicationDbContext context, IMa
_mapper = mapper;
}

public void Test()
{
var test1 = _context.Get<Order>().Where(c => c.LaundryStore.Id == 1).ToList();
}




public async Task<PaginatedList<TodoItemBriefDto>> Handle(GetTodoItemsWithPaginationQuery request, CancellationToken cancellationToken)
{
Expand Down
10 changes: 3 additions & 7 deletions src/Domain/Entities/Customer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.ComponentModel.DataAnnotations.Schema;
using SWD_Laundry_Backend.Domain.Entities.Validation;
using SWD_Laundry_Backend.Domain.IdentityModel;

namespace SWD_Laundry_Backend.Domain.Entities;
Expand All @@ -8,24 +7,21 @@ namespace SWD_Laundry_Backend.Domain.Entities;

public class Customer : BaseAuditableEntity
{
//public string Name { get; set; }
//public string Name { get; set; }
//public string Address { get; set; }

#region Relationship

[ForeignKey("Building")]
public int BuildingID { get; set; }

[ForeignKey("Wallet")]
public int WalletID { get; set; }

[ForeignKey("ApplicationUser")]
public string ApplicationUserID { get; set; }

public Building Building { get; set; }
public Wallet Wallet { get; set; }

public ApplicationUser ApplicationUser { get; set; }
//public virtual List<Order> Order { get; set; }
public virtual List<Order> Order { get; set; }

#endregion Relationship

Expand Down
7 changes: 0 additions & 7 deletions src/Domain/Entities/LaundryStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,7 @@ public class LaundryStore : BaseAuditableEntity
[ForeignKey("ApplicationUser")]
public string ApplicationUserID { get; set; }

[ForeignKey("Wallet")]
public int WalletID { get; set; }

public ApplicationUser ApplicationUser { get; set; }
public Wallet Wallet { get; set; }


public virtual List<Order> Orders { get; set; }

#endregion Relationship
}
22 changes: 22 additions & 0 deletions src/Domain/Entities/LaundryStoreOrder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.ComponentModel.DataAnnotations.Schema;

namespace SWD_Laundry_Backend.Domain.Entities;

public class LaundryStoreOrder : BaseAuditableEntity
#nullable disable
{
public bool IsDone { get; set; }

#region Relationship

[ForeignKey("Order")]
public int OrderID { get; set; }

[ForeignKey("LaundryStore")]
public int LaundryStoreID { get; set; }

public LaundryStore LaundryStore { get; set; }
public Order Order { get; set; }

#endregion Relationship
}
22 changes: 4 additions & 18 deletions src/Domain/Entities/Order.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
using System.ComponentModel.DataAnnotations.Schema;
using SWD_Laundry_Backend.Domain.IdentityModel;

namespace SWD_Laundry_Backend.Domain.Entities;
#nullable disable

public class Order : BaseAuditableEntity
{
public DateTime OrderDate { get; set; } = DateTime.Now;

public DateTime ShipDate { get; set; }

public TimeFrame TimeFrame { get; set; }
public DateTime ExpectedFinishDate { get; set; }
public string Address { get; set; } // Address = Customer's building location
public short Amount { get; set; }
Expand All @@ -24,24 +21,13 @@ public class Order : BaseAuditableEntity
[ForeignKey("Customer")]
public int CustomerID { get; set; }

//[ForeignKey("LaundryStore")]
//public int LaundryStoreID { get; set; }

////[ForeignKey("Staff")]
////public int StaffID { get; set; }

//[ForeignKey("Service")]
//public int ServiceID { get; set; }

////===========================
public Service Service { get; set; }

public virtual LaundryStore LaundryStore { get; set; }
public virtual Customer Customer { get; set; }
public virtual Staff Staff { get; set; }
public Customer Customer { get; set; }

public PaymentMethod PaymentMethod { get; set; }
public List<OrderHistory> OrderHistories { get; set; }
public List<StaffOrder> StaffOrders { get; set; }
//public LaundryStoreOrder LaundryStoreOrder { get; set; }

#endregion Relationship

Expand Down
14 changes: 1 addition & 13 deletions src/Domain/Entities/OrderHistory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,7 @@ public class OrderHistory : BaseAuditableEntity

#region Special attributes

//private string _orderstatus;

//public string Status
//{
// get { return _orderstatus; }
// set
// {
// _orderstatus = new Validate().IsValidTripStatus(value)
// ? value
// : throw new ArgumentException("Invalid order status {FINISHED, PROCESSING, CANCELLED}.");
// }
//}
public Status Status { get; set;}
public OrderStatus Status { get; set;}

#endregion Special attributes
}
13 changes: 2 additions & 11 deletions src/Domain/Entities/PaymentMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,9 @@ public class PaymentMethod : BaseAuditableEntity

#region Special Attributes


//public string PaymentType
//{
// get { return _type; }
// set
// {
// _type = new Validate().IsValidPayment(value)
// ? value
// : throw new ArgumentException("Invalid payment type{CASH , PAYPAL}.");
// }
//}
public string Name { get; set; }


#endregion Special Attributes

}
21 changes: 0 additions & 21 deletions src/Domain/Entities/Service.cs

This file was deleted.

16 changes: 3 additions & 13 deletions src/Domain/Entities/Staff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,19 @@ namespace SWD_Laundry_Backend.Domain.Entities;

public class Staff : BaseAuditableEntity
{
//public DateTime Dob { get; set; }
//public string Address { get; set; }
public DateTime Dob { get; set; }
public string Address { get; set; }
public double Salary { get; set; }

#region Relationship

[ForeignKey("Wallet")]
public int WalletID { get; set; }

[ForeignKey("ApplicationUser")]
public string ApplicationUserID { get; set; }

public ApplicationUser ApplicationUser { get; set; }
public Wallet Wallet { get; set; }

public List<Order> Order { get; set; }
public List<Staff_Trip> Staff_Trips { get; set; }
public List<StaffOrder> StaffOrders { get; set; }

#endregion Relationship

#region Special Attribute

public StaffRole StaffRole { get; set; }

#endregion Special Attribute
}
28 changes: 28 additions & 0 deletions src/Domain/Entities/StaffOrder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SWD_Laundry_Backend.Domain.Entities;
#nullable disable

public class StaffOrder : BaseAuditableEntity
{
public bool IsDone { get; set; }
public StaffOrderType Type { get; set; }

#region Relationship

[ForeignKey("Staff")]
public int StaffID { get; set; }

[ForeignKey("Order")]
public int OrderID { get; set; }

public Staff Staff { get; set; }
public Order Order { get; set; }

#endregion Relationship
}
2 changes: 1 addition & 1 deletion src/Domain/Entities/Staff_Trip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class Staff_Trip : BaseAuditableEntity

#region Special Attribute

public Status TripStatus { get; set; }
public OrderStatus TripStatus { get; set; }

#endregion Special Attribute
}
5 changes: 3 additions & 2 deletions src/Domain/Entities/TimeSchedule.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
namespace SWD_Laundry_Backend.Domain.Entities;
#nullable disable

public class TimeSchedule : BaseAuditableEntity
{
{
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }

#region Special Attribute

public DayOfWeek DayOfWeek { get; set; }
public TimeFrame TimeFrame { get; set; }
public Staff_Trip Staff_Trip { get; set; }
public List<Staff_Trip> Staff_Trip { get; set; }

#endregion Special Attribute
}
2 changes: 1 addition & 1 deletion src/Domain/Entities/Transaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class Transaction : BaseAuditableEntity

public AllowedTransactionType TransactionType { get; set; }

public Status Status { get; set; }
public OrderStatus Status { get; set; }

#endregion Special Attribute
}
9 changes: 5 additions & 4 deletions src/Domain/Entities/Wallet.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace SWD_Laundry_Backend.Domain.Entities;
using SWD_Laundry_Backend.Domain.IdentityModel;

namespace SWD_Laundry_Backend.Domain.Entities;
#nullable disable

public class Wallet : BaseAuditableEntity
Expand All @@ -8,9 +10,8 @@ public class Wallet : BaseAuditableEntity
#region Relationship

public List<Transaction> Transactions { get; set; }
public Customer Customer { get; set; }
public LaundryStore LaundryStore { get; set; }
public Staff Staff { get; set; }

public ApplicationUser ApplicationUser { get; set; }

#endregion Relationship
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace SWD_Laundry_Backend.Domain.Enums;
public enum Status
public enum OrderStatus
{
Pending = 1,
Pending = 1,
Processing = 2,
Completed = 3,
Cancelled = 4
Expand Down
13 changes: 13 additions & 0 deletions src/Domain/Enums/StaffOrderType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SWD_Laundry_Backend.Domain.Enums;

public enum StaffOrderType
{
CollectFromCustomer = 0,
DeliveryToCustomer = 1
}
Loading

0 comments on commit b8c0370

Please sign in to comment.