# 📝 Changelog - ۲۳ دی ۱۴۰۴ (13 January 2025)

> **Session**: تکمیل BackOffice.BFF WebApi Services برای Discount Shop

---

## 🎯 خلاصه تغییرات

تکمیل لایه gRPC Services برای BackOffice.BFF - بخش فروشگاه تخفیفی

---

## 🆕 WebApi Services جدید

### DiscountCategoryService.cs
**مسیر**: `BackOffice.BFF.WebApi/Services/DiscountCategoryService.cs`

| RPC | Command/Query |
|-----|---------------|
| `Create` | `CreateDiscountCategoryCommand` |
| `Update` | `UpdateDiscountCategoryCommand` |
| `Delete` | `DeleteDiscountCategoryCommand` |
| `GetDiscountCategories` | `GetDiscountCategoriesQuery` |

---

### DiscountShoppingCartService.cs
**مسیر**: `BackOffice.BFF.WebApi/Services/DiscountShoppingCartService.cs`

| RPC | Command/Query |
|-----|---------------|
| `AddToCart` | `AddToCartCommand` |
| `RemoveFromCart` | `RemoveFromCartCommand` |
| `UpdateCartItemCount` | `UpdateCartItemCountCommand` |
| `GetUserCart` | `GetUserCartQuery` |
| `ClearCart` | `ClearCartCommand` |

**توضیح**: این سرویس برای مدیریت سبد خرید کاربران توسط پشتیبانی/ادمین استفاده می‌شود.

---

### TagService.cs
**مسیر**: `BackOffice.BFF.WebApi/Services/TagService.cs`

| RPC | Command/Query |
|-----|---------------|
| `Create` | `CreateTagCommand` |
| `Update` | `UpdateTagCommand` |
| `Delete` | `DeleteTagCommand` |
| `Get` | `GetTagQuery` |
| `GetAll` | `GetAllTagsQuery` |
| `GetProductsByTag` | `GetProductsByTagQuery` |

---

### ProductTagService.cs
**مسیر**: `BackOffice.BFF.WebApi/Services/ProductTagService.cs`

| RPC | Command/Query |
|-----|---------------|
| `CreateNewProductTag` | `CreateProductTagCommand` |
| `UpdateProductTag` | `UpdateProductTagCommand` |
| `DeleteProductTag` | `DeleteProductTagCommand` |
| `GetProductTag` | `GetProductTagQuery` |
| `GetAllProductTagByFilter` | `GetAllProductTagsQuery` |

---

## 🔧 تغییرات Application Layer

### Handlers جدید ایجاد شده

#### ProductTagCQ/Commands/UpdateProductTag/
- `UpdateProductTagCommand.cs`
- `UpdateProductTagCommandHandler.cs`

#### ProductTagCQ/Commands/DeleteProductTag/
- `DeleteProductTagCommand.cs`
- `DeleteProductTagCommandHandler.cs`

#### ProductTagCQ/Queries/GetProductTag/
- `GetProductTagQuery.cs`
- `GetProductTagQueryHandler.cs`

#### ProductTagCQ/Queries/GetAllProductTags/
- `GetAllProductTagsQuery.cs`
- `GetAllProductTagsQueryHandler.cs`

---

### DiscountShoppingCartCQ - اصلاحات Proto

#### فایل‌های تغییر یافته:

**RemoveFromCartCommand.cs**
```diff
- public long CartItemId { get; init; }
+ public long ProductId { get; init; }
```

**UpdateCartItemCountCommand.cs**
```diff
- public long CartItemId { get; init; }
+ public long ProductId { get; init; }
```

**GetUserCartResponseDto.cs**
```diff
- public long UserId { get; set; }
- public long TotalDiscountedPrice { get; set; }
- public long TotalSavings { get; set; }
+ public long TotalDiscountAmount { get; set; }
+ public long FinalPrice { get; set; }
```

**CartItemDto**
```diff
- public long Id { get; set; }
- public long DiscountedPrice { get; set; }
- public DateTime AddedAt { get; set; }
+ public long DiscountAmount { get; set; }
+ public long FinalPrice { get; set; }
+ public int ProductRemainingCount { get; set; }
+ public DateTime Created { get; set; }
```

---

## 📦 تغییرات Proto Projects

### csproj تغییر یافته (GrpcServices: Client → Both)
- `BackOffice.BFF.DiscountCategory.Protobuf.csproj`
- `BackOffice.BFF.DiscountShoppingCart.Protobuf.csproj`
- `BackOffice.BFF.Tag.Protobuf.csproj`
- `BackOffice.BFF.ProductTag.Protobuf.csproj`

### WebApi.csproj - References اضافه شده
```xml
<ProjectReference Include="..\Protobufs\BackOffice.BFF.DiscountCategory.Protobuf\..." />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.DiscountShoppingCart.Protobuf\..." />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.Tag.Protobuf\..." />
<ProjectReference Include="..\Protobufs\BackOffice.BFF.ProductTag.Protobuf\..." />
```

---

## 🗑️ Excludes حذف شده

### BackOffice.BFF.Application.csproj
```diff
- <Compile Remove="DiscountShoppingCartCQ/**/*.cs" />
+ <!-- All excluded handlers have been enabled -->
```

---

## 📊 آمار نهایی

| متریک | مقدار |
|--------|-------|
| Services جدید | 4 |
| Handlers جدید | 8 |
| فایل‌های اصلاح شده | 12 |
| Proto projects تنظیم شده | 4 |

---

## ✅ نتیجه Build

```
Build succeeded.
    177 Warning(s)
    0 Error(s)
```
