Compare commits
No commits in common. "Task_1_Models" and "main" have entirely different histories.
Task_1_Mod
...
main
@ -1,12 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SweetBunsContracts.DataModels
|
|
||||||
{
|
|
||||||
internal class EmployeeDataModel
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SweetBunsContracts.DataModels
|
|
||||||
{
|
|
||||||
internal class IngredientDataModel
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using SweetBunsContracts.Enums;
|
|
||||||
using SweetBunsContracts.Exceptions;
|
|
||||||
using SweetBunsContracts.Extensions;
|
|
||||||
using SweetBunsContracts.Infrastructure;
|
|
||||||
|
|
||||||
namespace SweetBunsContracts.DataModels;
|
|
||||||
|
|
||||||
public class PostDataModel(string id, string postId, string postName, PostType postType, double salary, bool isActual, DateTime changeDate) : IValidation
|
|
||||||
{
|
|
||||||
public string Id { get; private set; } = id;
|
|
||||||
|
|
||||||
public string PostId { get; private set; } = postId;
|
|
||||||
|
|
||||||
public string PostName { get; private set; } = postName;
|
|
||||||
|
|
||||||
public PostType PostType { get; private set; } = postType;
|
|
||||||
|
|
||||||
public double Salary { get; private set; } = salary;
|
|
||||||
|
|
||||||
public bool IsActual { get; private set; } = isActual;
|
|
||||||
|
|
||||||
public DateTime ChangeDate { get; private set; } = changeDate;
|
|
||||||
|
|
||||||
public void Validate()
|
|
||||||
{
|
|
||||||
if (Id.IsEmpty())
|
|
||||||
throw new ValidationException("Field Id is empty");
|
|
||||||
|
|
||||||
if (!Id.IsGuid())
|
|
||||||
throw new ValidationException("The value in the field Id is not a unique identifier");
|
|
||||||
|
|
||||||
if (PostId.IsEmpty())
|
|
||||||
throw new ValidationException("Field PostId is empty");
|
|
||||||
|
|
||||||
if (!PostId.IsGuid())
|
|
||||||
throw new ValidationException("The value in the field PostId is not a unique identifier");
|
|
||||||
|
|
||||||
if (PostName.IsEmpty())
|
|
||||||
throw new ValidationException("Field PostName is empty");
|
|
||||||
|
|
||||||
if (PostType == PostType.None)
|
|
||||||
throw new ValidationException("Field PostType is empty");
|
|
||||||
|
|
||||||
if (Salary <= 0)
|
|
||||||
throw new ValidationException("Field Salary is empty");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using SweetBunsContracts.Enums;
|
|
||||||
using SweetBunsContracts.Exceptions;
|
|
||||||
using SweetBunsContracts.Extensions;
|
|
||||||
using SweetBunsContracts.Infrastructure;
|
|
||||||
|
|
||||||
namespace SweetBunsContracts.DataModels;
|
|
||||||
|
|
||||||
public class ProductDataModel(string id, string productName, ProductType productType, double price, bool isDeleted) : IValidation
|
|
||||||
{
|
|
||||||
public string Id { get; private set; } = id;
|
|
||||||
|
|
||||||
public string ProductName { get; private set; } = productName;
|
|
||||||
|
|
||||||
public ProductType ProductType { get; private set; } = productType;
|
|
||||||
|
|
||||||
public double Price { get; private set; } = price;
|
|
||||||
|
|
||||||
public bool IsDeleted { get; private set; } = isDeleted;
|
|
||||||
|
|
||||||
public void Validate()
|
|
||||||
{
|
|
||||||
if (Id.IsEmpty())
|
|
||||||
throw new ValidationException("Field Id is empty");
|
|
||||||
|
|
||||||
if (!Id.IsGuid())
|
|
||||||
throw new ValidationException("The value in the field Id is not a unique identifier");
|
|
||||||
|
|
||||||
if (ProductName.IsEmpty())
|
|
||||||
throw new ValidationException("Field ProductName is empty");
|
|
||||||
|
|
||||||
if (ProductType == ProductType.None)
|
|
||||||
throw new ValidationException("Field ProductType is empty");
|
|
||||||
|
|
||||||
if (Price <= 0)
|
|
||||||
throw new ValidationException("Field Price is less than or equal to 0");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SweetBunsContracts.DataModels
|
|
||||||
{
|
|
||||||
internal class ProductIngridientDataModel
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,31 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using SweetBunsContracts.Exceptions;
|
|
||||||
using SweetBunsContracts.Extensions;
|
|
||||||
using SweetBunsContracts.Infrastructure;
|
|
||||||
|
|
||||||
namespace SweetBunsContracts.DataModels;
|
|
||||||
|
|
||||||
public class SalaryDataModel(string workerId, DateTime salaryDate, double workerSalary) : IValidation
|
|
||||||
{
|
|
||||||
public string WorkerId { get; private set; } = workerId;
|
|
||||||
|
|
||||||
public DateTime SalaryDate { get; private set; } = salaryDate;
|
|
||||||
|
|
||||||
public double Salary { get; private set; } = workerSalary;
|
|
||||||
|
|
||||||
public void Validate()
|
|
||||||
{
|
|
||||||
if (WorkerId.IsEmpty())
|
|
||||||
throw new ValidationException("Field WorkerId is empty");
|
|
||||||
|
|
||||||
if (!WorkerId.IsGuid())
|
|
||||||
throw new ValidationException("The value in the field WorkerId is not a unique identifier");
|
|
||||||
|
|
||||||
if (Salary <= 0)
|
|
||||||
throw new ValidationException("Field Salary is less than or equal to 0");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SweetBunsContracts.DataModels
|
|
||||||
{
|
|
||||||
internal class SaleDataModel
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SweetBunsContracts.Enums;
|
|
||||||
|
|
||||||
public enum PostType
|
|
||||||
{
|
|
||||||
None = 0,
|
|
||||||
Confectioner = 1,
|
|
||||||
Baker = 2,
|
|
||||||
KitchenHelper = 3,
|
|
||||||
Salesman = 4
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SweetBunsContracts.Enums;
|
|
||||||
|
|
||||||
public enum ProductType
|
|
||||||
{
|
|
||||||
None = 0,
|
|
||||||
Bakery = 1,
|
|
||||||
Sweet = 2,
|
|
||||||
Blanks = 3,
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SweetBunsContracts.Exceptions;
|
|
||||||
|
|
||||||
public class ValidationException(string message) : Exception(message)
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SweetBunsContracts.Extensions;
|
|
||||||
|
|
||||||
public static class StringExtensions
|
|
||||||
{
|
|
||||||
public static bool IsEmpty(this string str)
|
|
||||||
{
|
|
||||||
return string.IsNullOrWhiteSpace(str);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsGuid(this string str)
|
|
||||||
{
|
|
||||||
return Guid.TryParse(str, out _);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SweetBunsContracts.Infrastructure;
|
|
||||||
public class IValidation
|
|
||||||
{
|
|
||||||
void Validate();
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user