estatedocflow / estatedocflow.api

0 stars 0 forks source link

House CRM API #7

Open estatedocflow opened 1 month ago

estatedocflow commented 1 month ago

Description:

This API will provide essential functionalities for managing house data, including property details, attachments, photos, and transaction status.

API Endpoints Definition:

1. Get Houses Endpoint: GET /api/houses Description: Retrieve a list of all houses. Response: Array of HouseDto objects representing each house.

2. Get House by ID Endpoint: GET /api/houses/{id} Description: Retrieve details of a specific house by its ID. Parameters: {id}: Unique identifier of the house. Response: HouseDto object representing the house with the specified ID.

3. Create House Endpoint: POST /api/houses Description: Create a new house entry. Request Body: CreateHouseDto object containing house details. Response: HouseDto object representing the newly created house.

4. Update House Endpoint: PUT /api/houses/{id} Description: Update all fields of a house identified by its ID. Parameters: {id}: Unique identifier of the house to update. Request Body: UpdateHouseDto object containing updated house details. Response: HouseDto object representing the updated house.

5. Partial Update of House (PATCH) Endpoint: PATCH /api/houses/{id} Description: Partially update specific fields of a house identified by its ID. Parameters: {id}: Unique identifier of the house to update. Request Body: JSON object containing fields to update (PatchHouseDto). Response: HouseDto object representing the updated house.

6. Delete House Endpoint: DELETE /api/houses/{id} Description: Delete a house by its ID. Parameters: {id}: Unique identifier of the house to delete. Response: HTTP status indicating success or failure of the deletion operation.

7. Patch House Photo Endpoint: PATCH /api/houses/{id}/photo Description: Update or add photos for a specific house. Parameters: {id}: Unique identifier of the house to update. Request Body: Array of photo URLs (PatchPhotoDto). Response: HouseDto object representing the updated house with the new photos.

8. Patch House Document Endpoint: PATCH /api/houses/{id}/document Description: Update or add documents for a specific house. Parameters: {id}: Unique identifier of the house to update. Request Body: Array of document details (PatchDocumentDto). Response: HouseDto object representing the updated house with the new documents.

9. Patch House State Endpoint: PATCH /api/houses/{id}/state Description: Update the state of a house identified by its ID. Parameters: {id}: Unique identifier of the house to update. Request Body: JSON object containing the new state (PatchHouseStateDto). Response: HouseDto object representing the updated house.

Data Transfer Objects (DTOs):

public enum HouseState
{
    [Description("Draft")]
    Draft,

    [Description("For Sale")]
    ForSale,

    [Description("Under Negotiation")]
    UnderNegotiation,

    [Description("Sold")]
    Sold
}
public class HouseDto
{
    public Guid HouseId { get; set; }
    public string Address { get; set; }
    public string City { get; set; }
    public string OwnerFirstName { get; set; }
    public string OwnerLastName { get; set; }
    public string Description { get; set; }
    public HouseState State { get; set; }
    public List<AttachmentDto> Attachments { get; set; }
    public List<PhotoDto> Photos { get; set; }
}
public class CreateHouseDto
{
    public string Address { get; set; }
    public string City { get; set; }
    public string OwnerFirstName { get; set; }
    public string OwnerLastName { get; set; }
    public string Description { get; set; }
}
public class UpdateHouseDto
{
    public string Address { get; set; }
    public string City { get; set; }
    public string OwnerFirstName { get; set; }
    public string OwnerLastName { get; set; }
    public string Description { get; set; }
}
public class PatchPhotoDto
{
    public List<string> PhotoUrls { get; set; }
}
public class PatchDocumentDto
{
    public List<DocumentDto> Documents { get; set; }
}
public class DocumentDto
{
    public string DocumentType { get; set; }
    public string DocumentUrl { get; set; }
}
public class PatchHouseStateDto
{
    public HouseState State { get; set; }
}
estatedocflow commented 1 month ago

@Riya2993 sign here working hours, please!

You missed also the PR to merge it in the dev branch, please added it.

estatedocflow commented 1 month ago

@Riya2993 I saw your changes, please don't change the SDK version, use .NET 8.

Riya2993 commented 1 month ago

I have added the entity for House and HousePhoto public class House { [Key] public Guid Id { get; set; }
public string Address { get; set; } public string City { get; set; } public string OwnerFirstName { get; set; } public string OwnerLastName { get; set; } public string Description { get; set; } public HouseState State { get; set; } public virtual IEnumerable? HousePhotos { get; set; } }

public class HousePhoto
{
    [Key]
    public Guid Id { get; set; }

    [Required]
    [ForeignKey("House")]
    public Guid HouseId { get; set; }
    public string PhotoUrl { get; set; }
    public virtual House House { get; set; }
}

Also, I cannot see the AttachmentDto, just can see its use in the HouseDto model.

Merged Main into Dev with latest changes

estatedocflow commented 1 month ago

@Riya2993 you're right, you can delete the HousePhoto model and create a generic HouseAttachment, with an additional field called DocumentType (it will be an enum, and at the moment we only have Photo - 0, Document - 1)

Riya2993 commented 1 month ago

DocumentType save as 0 and 1 in HouseAttachment table ?

Riya2993 commented 1 month ago

public class House { [Key] public Guid Id { get; set; }
public string Address { get; set; } public string City { get; set; } public string OwnerFirstName { get; set; } public string OwnerLastName { get; set; } public string Description { get; set; } public HouseState State { get; set; } public virtual IEnumerable? HouseAttachments { get; set; } }

public class HouseAttachment
{
    [Key]
    public Guid Id { get; set; }

    [Required]
    [ForeignKey("House")]
    public Guid HouseId { get; set; }
    public string PhotoUrl { get; set; }
    public DocumentType DocumentType { get; set; }
    public virtual Models.Entities.House.House House { get; set; }
}

It is correct entity now ?

estatedocflow commented 1 month ago

yes is correct, ok 0 and 1 is enought

Riya2993 commented 1 month ago
  1. Patch House Photo
  2. Patch House Document

How we need to generate Image and Document Url? Also from request in which type of format Url get?

Riya2993 commented 1 month ago
  1. Partial Update of House (PATCH) Endpoint: PATCH /api/houses/{id} Description: Partially update specific fields of a house identified by its ID. Parameters: {id}: Unique identifier of the house to update. Request Body: JSON object containing fields to update (PatchHouseDto). Response: HouseDto object representing the updated house.

PatchHouseDto is not defined and which specific fields is required to update.

estatedocflow commented 1 month ago

@Riya2993 Patch House Photo Patch House Document How we need to generate Image and Document Url? Also from request in which type of format Url get?

we'll store the document and image in an AWS S3 bucket, so it will be a GUID. WDYT?

Partial Update of House (PATCH) Endpoint: PATCH /api/houses/{id} Description: Partially update specific fields of a house identified by its ID. Parameters: {id}: Unique identifier of the house to update. Request Body: JSON object containing fields to update (PatchHouseDto). Response: HouseDto object representing the updated house. PatchHouseDto is not defined and which specific fields is required to update.

You're right... it is a refuse... ignore it. Thanks

Riya2993 commented 1 month ago

To store documents in Amazon s3 bucket, we need AWS credentials(like accessKey and secreyKey) and the name of the bucket. So, after storing Image in document we'll get ImageUrl(string).

estatedocflow commented 1 month ago

@Riya2993 yeas of course, but we'll do this in another issue, at the moment you only build the structure to do that. ok?

Riya2993 commented 1 month ago

Total hours for implementation: 4

Riya2993 commented 1 month ago

Additional hours spent for resolving - 2