Commit 4a4eeb53 authored by hasan khaddour's avatar hasan khaddour

add domain exceptions and enitiy abstraction

parent d57d3621
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ApplicationDomain.Abstraction
{
public interface IEntityBase<T>
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public T Id { get; set; }
}
}
...@@ -7,8 +7,12 @@ namespace ApplicationDomain.Abstraction ...@@ -7,8 +7,12 @@ namespace ApplicationDomain.Abstraction
{ {
IGenericRepository<T> Entity { get; } IGenericRepository<T> Entity { get; }
IIngredientRepository Ingredients { get; }
IMedicalStateRepository MedicalStates { get; }
IPatientRepository Patients { get; }
IMedicineRepository Medicines { get; }
void Save(); void Commit();
// void Rollback();
} }
} }
using System; using ApplicationDomain.Abstraction;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
...@@ -8,9 +9,8 @@ using System.Threading.Tasks; ...@@ -8,9 +9,8 @@ using System.Threading.Tasks;
namespace ApplicationDomain.Entities namespace ApplicationDomain.Entities
{ {
public class EntityBase public class EntityBase : IEntityBase<int>
{ {
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; } public int Id { get; set; }
......
...@@ -6,14 +6,14 @@ using System.Threading.Tasks; ...@@ -6,14 +6,14 @@ using System.Threading.Tasks;
namespace ApplicationDomain.Exceptions namespace ApplicationDomain.Exceptions
{ {
public class CoreException : Exception public class DomainException : Exception
{ {
internal CoreException(string businessMessage) internal DomainException(string businessMessage)
: base(businessMessage) : base(businessMessage)
{ {
} }
internal CoreException(string message, Exception innerException) internal DomainException(string message, Exception innerException)
: base(message, innerException) : base(message, innerException)
{ {
} }
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ApplicationDomain.Exceptions
{
public class NotFoundException : DomainException
{
public NotFoundException() : this("Not found")
{
}
public NotFoundException(string message) : base(message)
{
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ApplicationDomain.Exceptions
{
public sealed class UnAuthorizedException : DomainException
{
public UnAuthorizedException() : this("Not found")
{
}
public UnAuthorizedException(string message) : base(message)
{
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment