Skip to content

Commit

Permalink
updated models to also support no-sql. disabled docker-publish for now
Browse files Browse the repository at this point in the history
The Backend was not updated with the new data
  • Loading branch information
fokklz committed Jan 13, 2024
1 parent 27dd34b commit 5de1b62
Show file tree
Hide file tree
Showing 25 changed files with 284 additions and 110 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Docker Image CI

on:
push:
branches: [main]
branches: [mainxx]
pull_request:
branches: [main]
branches: [mainxx]

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion SkiServiceModels/DTOs/Responses/DeleteResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ namespace SkiServiceModels.DTOs.Responses
/// </summary>
public class DeleteResponse : IResponseDTO
{
public int Id { get; set; }
public int Count { get; set; }
}
}
7 changes: 7 additions & 0 deletions SkiServiceModels/Interfaces/IGenericBSONModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace SkiServiceModels.Interfaces
{
public interface IGenericBSONModel : IGenericModel
{
public string Id { get; set; }
}
}
7 changes: 7 additions & 0 deletions SkiServiceModels/Interfaces/IGenericEFModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace SkiServiceModels.Interfaces
{
public interface IGenericEFModel : IGenericModel
{
public int Id { get; set; }
}
}
3 changes: 0 additions & 3 deletions SkiServiceModels/Interfaces/IGenericModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
{
public interface IGenericModel
{
int Id { get; set; }

bool IsDeleted { get; set; }

}
}
8 changes: 1 addition & 7 deletions SkiServiceModels/Interfaces/ILoginRequest.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SkiServiceModels.Interfaces
namespace SkiServiceModels.Interfaces
{
public interface ILoginRequest : IRequestDTO
{
Expand Down
29 changes: 29 additions & 0 deletions SkiServiceModels/Models/BSON/Order.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using SkiServiceModels.Interfaces;
using SkiServiceModels.Models.Base;

namespace SkiServiceModels.Models.BSON
{
public class Order : OrderBase, IGenericBSONModel
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }

public string PriorityId { get; set; }
public string ServiceId { get; set; }
public string StateId { get; set; }
public string? UserId { get; set; } = null;

[BsonIgnore]
public virtual Priority Priority { get; set; }
[BsonIgnore]
public virtual Service Service { get; set; }
[BsonIgnore]
public virtual State State { get; set; }
[BsonIgnore]
public virtual User? User { get; set; }

}
}
14 changes: 14 additions & 0 deletions SkiServiceModels/Models/BSON/Priority.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using SkiServiceModels.Interfaces;
using SkiServiceModels.Models.Base;

namespace SkiServiceModels.Models.BSON
{
public class Priority : PriorityBase, IGenericBSONModel
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }
}
}
14 changes: 14 additions & 0 deletions SkiServiceModels/Models/BSON/Service.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using SkiServiceModels.Interfaces;
using SkiServiceModels.Models.Base;

namespace SkiServiceModels.Models.BSON
{
public class Service : ServiceBase, IGenericBSONModel
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }
}
}
14 changes: 14 additions & 0 deletions SkiServiceModels/Models/BSON/State.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using SkiServiceModels.Interfaces;
using SkiServiceModels.Models.Base;

namespace SkiServiceModels.Models.BSON
{
public class State : StateBase, IGenericBSONModel
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }
}
}
14 changes: 14 additions & 0 deletions SkiServiceModels/Models/BSON/User.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using SkiServiceModels.Interfaces;
using SkiServiceModels.Models.Base;

namespace SkiServiceModels.Models.BSON
{
public class User : UserBase, IGenericBSONModel
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }

Check warning on line 12 in SkiServiceModels/Models/BSON/User.cs

View workflow job for this annotation

GitHub Actions / build-and-publish

Non-nullable property 'Id' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
}
}
25 changes: 25 additions & 0 deletions SkiServiceModels/Models/Base/OrderBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using SkiServiceModels.Interfaces;
using System.ComponentModel.DataAnnotations;

namespace SkiServiceModels.Models.Base
{
public class OrderBase : IGenericModel
{
[StringLength(50)]
public required string Name { get; set; }

[StringLength(100)]
public required string Email { get; set; }

[StringLength(20)]
public required string Phone { get; set; }

[StringLength(1000)]
public string? Note { get; set; } = null;

public DateTime Created { get; set; } = DateTime.Now;

public bool IsDeleted { get; set; } = false;

}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
using SkiServiceModels.Interfaces;
using System.ComponentModel.DataAnnotations;

namespace SkiServiceModels
namespace SkiServiceModels.Models.Base
{
public class Priority : IGenericModel
public class PriorityBase : IGenericModel
{
[Key]
public int Id { get; set; }

[StringLength(20)]
public string Name { get; set; }
public required string Name { get; set; }

public int Days { get; set; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
using SkiServiceModels.Interfaces;
using System.ComponentModel.DataAnnotations;

namespace SkiServiceModels
namespace SkiServiceModels.Models.Base
{
public class Service : IGenericModel
public class ServiceBase : IGenericModel
{
[Key]
public int Id { get; set; }

[StringLength(50)]
public string Name { get; set; }
public required string Name { get; set; }

[StringLength(1000)]
public string Description { get; set; }
public required string Description { get; set; }

public int Price { get; set; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
using SkiServiceModels.Interfaces;
using System.ComponentModel.DataAnnotations;

namespace SkiServiceModels
namespace SkiServiceModels.Models.Base
{
public class State : IGenericModel
public class StateBase : IGenericModel
{

[Key]
public int Id { get; set; }

[StringLength(20)]
public string Name { get; set; }
public required string Name { get; set; }

public bool IsDeleted { get; set; } = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@
using SkiServiceModels.Enums;
using SkiServiceModels.Interfaces;

#nullable disable

namespace SkiServiceModels
namespace SkiServiceModels.Models.Base
{
public class User : IGenericModel
public class UserBase : IGenericModel
{
[Key]
public int Id { get; set; }

[StringLength(50)]
public string Username { get; set; }
public required string Username { get; set; }

public byte[] PasswordHash { get; set; }

Check warning on line 12 in SkiServiceModels/Models/Base/UserBase.cs

View workflow job for this annotation

GitHub Actions / build-and-publish

Non-nullable property 'PasswordHash' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

Expand All @@ -24,8 +19,9 @@ public class User : IGenericModel

public int LoginAttempts { get; set; } = 0;

public string RefreshToken { get; set; } = null;

Check warning on line 22 in SkiServiceModels/Models/Base/UserBase.cs

View workflow job for this annotation

GitHub Actions / build-and-publish

Cannot convert null literal to non-nullable reference type.

public bool IsDeleted { get; set; } = false;

public string RefreshToken { get; set; } = null;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using SkiServiceModels.Interfaces;
using SkiServiceModels.Models.Base;
using System.ComponentModel.DataAnnotations;

namespace SkiServiceModels
namespace SkiServiceModels.Models.EF
{
public class Order : IGenericModel
public class Order : OrderBase, IGenericEFModel
{
[Key]
public int Id { get; set; }
Expand All @@ -17,24 +18,7 @@ public class Order : IGenericModel
// Navigation properties
public virtual User? User { get; set; }
public virtual Service Service { get; set; }

Check warning on line 20 in SkiServiceModels/Models/EF/Order.cs

View workflow job for this annotation

GitHub Actions / build-and-publish

Non-nullable property 'Service' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public virtual Priority Priority { get; set; }
public virtual Priority Priority { get; set; }

Check warning on line 21 in SkiServiceModels/Models/EF/Order.cs

View workflow job for this annotation

GitHub Actions / build-and-publish

Non-nullable property 'Priority' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public virtual State State { get; set; }

Check warning on line 22 in SkiServiceModels/Models/EF/Order.cs

View workflow job for this annotation

GitHub Actions / build-and-publish

Non-nullable property 'State' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.

[StringLength(50)]
public string Name { get; set; }

[StringLength(100)]
public string Email { get; set; }

[StringLength(20)]
public string Phone { get; set; }

[StringLength(1000)]
public string? Note { get; set; } = null;

public DateTime Created { get; set; } = DateTime.Now;

public bool IsDeleted { get; set; } = false;

}
}
12 changes: 12 additions & 0 deletions SkiServiceModels/Models/EF/Priority.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using SkiServiceModels.Interfaces;
using SkiServiceModels.Models.Base;
using System.ComponentModel.DataAnnotations;

namespace SkiServiceModels.Models.EF
{
public class Priority : PriorityBase, IGenericEFModel
{
[Key]
public int Id { get; set; }
}
}
12 changes: 12 additions & 0 deletions SkiServiceModels/Models/EF/Service.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using SkiServiceModels.Interfaces;
using SkiServiceModels.Models.Base;
using System.ComponentModel.DataAnnotations;

namespace SkiServiceModels.Models.EF
{
public class Service : ServiceBase, IGenericEFModel
{
[Key]
public int Id { get; set; }
}
}
12 changes: 12 additions & 0 deletions SkiServiceModels/Models/EF/State.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using SkiServiceModels.Interfaces;
using SkiServiceModels.Models.Base;
using System.ComponentModel.DataAnnotations;

namespace SkiServiceModels.Models.EF
{
public class State : StateBase, IGenericEFModel
{
[Key]
public int Id { get; set; }
}
}
12 changes: 12 additions & 0 deletions SkiServiceModels/Models/EF/User.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using SkiServiceModels.Interfaces;
using SkiServiceModels.Models.Base;
using System.ComponentModel.DataAnnotations;

namespace SkiServiceModels.Models.EF
{
public class User : UserBase, IGenericEFModel
{
[Key]
public int Id { get; set; }
}
}
Binary file modified SkiServiceModels/README.md
Binary file not shown.
Loading

0 comments on commit 5de1b62

Please sign in to comment.