initial commit
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
using Indotalent.ConfigBackEnd.Extensions;
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
|
||||
namespace Indotalent.Features.Thirdparty.Patient.Cqrs;
|
||||
|
||||
public class CreatePatientContactRequest
|
||||
{
|
||||
public string? PatientId { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Title { get; set; }
|
||||
public string? PhoneNumber { get; set; }
|
||||
public string? EmailAddress { get; set; }
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
|
||||
public class CreatePatientContactResponse
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
|
||||
public record CreatePatientContactCommand(CreatePatientContactRequest Data) : IRequest<CreatePatientContactResponse>;
|
||||
|
||||
public class CreatePatientContactHandler : IRequestHandler<CreatePatientContactCommand, CreatePatientContactResponse>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public CreatePatientContactHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<CreatePatientContactResponse> Handle(CreatePatientContactCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var entityName = nameof(Data.Entities.PatientContact);
|
||||
|
||||
var autoNo = await _context.GenerateAutoNumberAsync(
|
||||
entityName: entityName,
|
||||
prefixTemplate: $"{entityName.ToShortNameConsonant(3)}/{{Year}}/",
|
||||
ct: cancellationToken
|
||||
);
|
||||
|
||||
var entity = new Data.Entities.PatientContact
|
||||
{
|
||||
AutoNumber = autoNo,
|
||||
PatientId = request.Data.PatientId,
|
||||
Name = request.Data.Name,
|
||||
Title = request.Data.Title,
|
||||
PhoneNumber = request.Data.PhoneNumber,
|
||||
EmailAddress = request.Data.EmailAddress,
|
||||
Description = request.Data.Description
|
||||
};
|
||||
|
||||
_context.PatientContact.Add(entity);
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return new CreatePatientContactResponse
|
||||
{
|
||||
Id = entity.Id,
|
||||
Name = entity.Name
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
using Indotalent.ConfigBackEnd.Exceptions;
|
||||
using Indotalent.ConfigBackEnd.Extensions;
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Indotalent.Features.Thirdparty.Patient.Cqrs;
|
||||
|
||||
public class CreatePatientRequest
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? Street { get; set; }
|
||||
public string? City { get; set; }
|
||||
public string? State { get; set; }
|
||||
public string? ZipCode { get; set; }
|
||||
public string? Country { get; set; }
|
||||
public string? PhoneNumber { get; set; }
|
||||
public string? FaxNumber { get; set; }
|
||||
public string? EmailAddress { get; set; }
|
||||
public string? Website { get; set; }
|
||||
public string? WhatsApp { get; set; }
|
||||
public string? LinkedIn { get; set; }
|
||||
public string? Facebook { get; set; }
|
||||
public string? Instagram { get; set; }
|
||||
public string? TwitterX { get; set; }
|
||||
public string? TikTok { get; set; }
|
||||
public string? PatientGroupId { get; set; }
|
||||
public string? PatientCategoryId { get; set; }
|
||||
}
|
||||
|
||||
public class CreatePatientResponse
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
|
||||
public record CreatePatientCommand(CreatePatientRequest Data) : IRequest<CreatePatientResponse>;
|
||||
|
||||
public class CreatePatientHandler : IRequestHandler<CreatePatientCommand, CreatePatientResponse>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public CreatePatientHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<CreatePatientResponse> Handle(CreatePatientCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var isExists = await _context.Patient
|
||||
.AnyAsync(x => x.Name == request.Data.Name, cancellationToken);
|
||||
|
||||
if (isExists)
|
||||
{
|
||||
throw new AlreadyExistsException("Patient", request.Data.Name ?? string.Empty);
|
||||
}
|
||||
|
||||
var entityName = nameof(Data.Entities.Patient);
|
||||
|
||||
var autoNo = await _context.GenerateAutoNumberAsync(
|
||||
entityName: entityName,
|
||||
prefixTemplate: $"{entityName.ToShortNameConsonant(3)}/{{Year}}/",
|
||||
ct: cancellationToken
|
||||
);
|
||||
|
||||
var entity = new Data.Entities.Patient
|
||||
{
|
||||
AutoNumber = autoNo,
|
||||
Name = request.Data.Name,
|
||||
Description = request.Data.Description,
|
||||
Street = request.Data.Street,
|
||||
City = request.Data.City,
|
||||
State = request.Data.State,
|
||||
ZipCode = request.Data.ZipCode,
|
||||
Country = request.Data.Country,
|
||||
PhoneNumber = request.Data.PhoneNumber,
|
||||
FaxNumber = request.Data.FaxNumber,
|
||||
EmailAddress = request.Data.EmailAddress,
|
||||
Website = request.Data.Website,
|
||||
WhatsApp = request.Data.WhatsApp,
|
||||
LinkedIn = request.Data.LinkedIn,
|
||||
Facebook = request.Data.Facebook,
|
||||
Instagram = request.Data.Instagram,
|
||||
TwitterX = request.Data.TwitterX,
|
||||
TikTok = request.Data.TikTok,
|
||||
PatientGroupId = request.Data.PatientGroupId,
|
||||
PatientCategoryId = request.Data.PatientCategoryId
|
||||
};
|
||||
|
||||
_context.Patient.Add(entity);
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return new CreatePatientResponse
|
||||
{
|
||||
Id = entity.Id,
|
||||
Name = entity.Name
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using FluentValidation;
|
||||
using Indotalent.Shared.Consts;
|
||||
|
||||
namespace Indotalent.Features.Thirdparty.Patient.Cqrs;
|
||||
|
||||
public class CreatePatientValidator : AbstractValidator<CreatePatientRequest>
|
||||
{
|
||||
public CreatePatientValidator()
|
||||
{
|
||||
RuleFor(x => x.Name)
|
||||
.NotEmpty().WithMessage("Patient Name is required")
|
||||
.MaximumLength(GlobalConsts.StringLengthShort);
|
||||
|
||||
RuleFor(x => x.EmailAddress)
|
||||
.EmailAddress().When(x => !string.IsNullOrEmpty(x.EmailAddress));
|
||||
|
||||
RuleFor(x => x.PatientGroupId)
|
||||
.NotEmpty().WithMessage("Patient Group is required");
|
||||
|
||||
RuleFor(x => x.PatientCategoryId)
|
||||
.NotEmpty().WithMessage("Patient Category is required");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Indotalent.Features.Thirdparty.Patient.Cqrs;
|
||||
|
||||
public record DeletePatientByIdRequest(string Id);
|
||||
|
||||
public record DeletePatientByIdCommand(DeletePatientByIdRequest Data) : IRequest<bool>;
|
||||
|
||||
public class DeletePatientByIdHandler : IRequestHandler<DeletePatientByIdCommand, bool>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public DeletePatientByIdHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<bool> Handle(DeletePatientByIdCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var entity = await _context.Patient
|
||||
.FirstOrDefaultAsync(x => x.Id == request.Data.Id, cancellationToken);
|
||||
|
||||
if (entity == null) return false;
|
||||
|
||||
_context.Patient.Remove(entity);
|
||||
return await _context.SaveChangesAsync(cancellationToken) > 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Indotalent.Features.Thirdparty.Patient.Cqrs;
|
||||
|
||||
public record DeletePatientContactCommand(string Id) : IRequest<bool>;
|
||||
|
||||
public class DeletePatientContactHandler : IRequestHandler<DeletePatientContactCommand, bool>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public DeletePatientContactHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<bool> Handle(DeletePatientContactCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var entity = await _context.PatientContact
|
||||
.FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken);
|
||||
|
||||
if (entity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_context.PatientContact.Remove(entity);
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Indotalent.Features.Thirdparty.Patient.Cqrs;
|
||||
|
||||
public class PatientContactItemResponse
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? AutoNumber { get; set; }
|
||||
public string? Title { get; set; }
|
||||
public string? PhoneNumber { get; set; }
|
||||
public string? EmailAddress { get; set; }
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
|
||||
public class GetPatientByIdResponse
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? AutoNumber { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? Street { get; set; }
|
||||
public string? City { get; set; }
|
||||
public string? State { get; set; }
|
||||
public string? ZipCode { get; set; }
|
||||
public string? Country { get; set; }
|
||||
public string? PhoneNumber { get; set; }
|
||||
public string? FaxNumber { get; set; }
|
||||
public string? EmailAddress { get; set; }
|
||||
public string? Website { get; set; }
|
||||
public string? WhatsApp { get; set; }
|
||||
public string? LinkedIn { get; set; }
|
||||
public string? Facebook { get; set; }
|
||||
public string? Instagram { get; set; }
|
||||
public string? TwitterX { get; set; }
|
||||
public string? TikTok { get; set; }
|
||||
public string? PatientGroupId { get; set; }
|
||||
public string? PatientCategoryId { get; set; }
|
||||
public DateTimeOffset? CreatedAt { get; set; }
|
||||
public string? CreatedBy { get; set; }
|
||||
public DateTimeOffset? UpdatedAt { get; set; }
|
||||
public string? UpdatedBy { get; set; }
|
||||
public List<PatientContactItemResponse> Contacts { get; set; } = new();
|
||||
}
|
||||
|
||||
public record GetPatientByIdQuery(string Id) : IRequest<GetPatientByIdResponse?>;
|
||||
|
||||
public class GetPatientByIdHandler : IRequestHandler<GetPatientByIdQuery, GetPatientByIdResponse?>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public GetPatientByIdHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<GetPatientByIdResponse?> Handle(GetPatientByIdQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
return await _context.Patient
|
||||
.AsNoTracking()
|
||||
.Include(x => x.PatientContactList)
|
||||
.Where(x => x.Id == request.Id)
|
||||
.Select(x => new GetPatientByIdResponse
|
||||
{
|
||||
Id = x.Id,
|
||||
AutoNumber = x.AutoNumber,
|
||||
Name = x.Name,
|
||||
Description = x.Description,
|
||||
Street = x.Street,
|
||||
City = x.City,
|
||||
State = x.State,
|
||||
ZipCode = x.ZipCode,
|
||||
Country = x.Country,
|
||||
PhoneNumber = x.PhoneNumber,
|
||||
FaxNumber = x.FaxNumber,
|
||||
EmailAddress = x.EmailAddress,
|
||||
Website = x.Website,
|
||||
WhatsApp = x.WhatsApp,
|
||||
LinkedIn = x.LinkedIn,
|
||||
Facebook = x.Facebook,
|
||||
Instagram = x.Instagram,
|
||||
TwitterX = x.TwitterX,
|
||||
TikTok = x.TikTok,
|
||||
PatientGroupId = x.PatientGroupId,
|
||||
PatientCategoryId = x.PatientCategoryId,
|
||||
CreatedAt = x.CreatedAt,
|
||||
CreatedBy = x.CreatedBy,
|
||||
UpdatedAt = x.UpdatedAt,
|
||||
UpdatedBy = x.UpdatedBy,
|
||||
Contacts = x.PatientContactList
|
||||
.OrderBy(c => c.Name)
|
||||
.Select(c => new PatientContactItemResponse
|
||||
{
|
||||
Id = c.Id,
|
||||
Name = c.Name,
|
||||
AutoNumber = c.AutoNumber,
|
||||
Title = c.Title,
|
||||
PhoneNumber = c.PhoneNumber,
|
||||
EmailAddress = c.EmailAddress,
|
||||
Description = c.Description
|
||||
}).ToList()
|
||||
})
|
||||
.FirstOrDefaultAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Indotalent.Features.Thirdparty.Patient.Cqrs;
|
||||
|
||||
public class GetPatientListResponse
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? AutoNumber { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? PhoneNumber { get; set; }
|
||||
public string? EmailAddress { get; set; }
|
||||
public string? PatientGroupName { get; set; }
|
||||
public string? PatientCategoryName { get; set; }
|
||||
}
|
||||
|
||||
public record GetPatientListQuery() : IRequest<List<GetPatientListResponse>>;
|
||||
|
||||
public class GetPatientListHandler : IRequestHandler<GetPatientListQuery, List<GetPatientListResponse>>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public GetPatientListHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<List<GetPatientListResponse>> Handle(GetPatientListQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
return await _context.Patient
|
||||
.AsNoTracking()
|
||||
.Include(x => x.PatientGroup)
|
||||
.Include(x => x.PatientCategory)
|
||||
.OrderBy(x => x.Name)
|
||||
.Select(x => new GetPatientListResponse
|
||||
{
|
||||
Id = x.Id,
|
||||
AutoNumber = x.AutoNumber,
|
||||
Name = x.Name,
|
||||
PhoneNumber = x.PhoneNumber,
|
||||
EmailAddress = x.EmailAddress,
|
||||
PatientGroupName = x.PatientGroup != null ? x.PatientGroup.Name : string.Empty,
|
||||
PatientCategoryName = x.PatientCategory != null ? x.PatientCategory.Name : string.Empty
|
||||
})
|
||||
.ToListAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Indotalent.Features.Thirdparty.Patient.Cqrs;
|
||||
|
||||
public class LookupPatientResponse
|
||||
{
|
||||
public List<LookupItem> PatientGroups { get; set; } = new();
|
||||
public List<LookupItem> PatientCategories { get; set; } = new();
|
||||
}
|
||||
|
||||
public class LookupItem
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
|
||||
public record LookupPatientQuery() : IRequest<LookupPatientResponse>;
|
||||
|
||||
public class LookupPatientHandler : IRequestHandler<LookupPatientQuery, LookupPatientResponse>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public LookupPatientHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<LookupPatientResponse> Handle(LookupPatientQuery request, CancellationToken cancellationToken)
|
||||
{
|
||||
var result = new LookupPatientResponse();
|
||||
|
||||
result.PatientGroups = await _context.PatientGroup
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Name)
|
||||
.Select(x => new LookupItem { Id = x.Id, Name = x.Name })
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
result.PatientCategories = await _context.PatientCategory
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Name)
|
||||
.Select(x => new LookupItem { Id = x.Id, Name = x.Name })
|
||||
.ToListAsync(cancellationToken);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Indotalent.Features.Thirdparty.Patient.Cqrs;
|
||||
|
||||
public class UpdatePatientContactRequest
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Title { get; set; }
|
||||
public string? PhoneNumber { get; set; }
|
||||
public string? EmailAddress { get; set; }
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
|
||||
public class UpdatePatientContactResponse
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public bool Success { get; set; }
|
||||
}
|
||||
|
||||
public record UpdatePatientContactCommand(UpdatePatientContactRequest Data) : IRequest<UpdatePatientContactResponse>;
|
||||
|
||||
public class UpdatePatientContactHandler : IRequestHandler<UpdatePatientContactCommand, UpdatePatientContactResponse>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public UpdatePatientContactHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<UpdatePatientContactResponse> Handle(UpdatePatientContactCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var entity = await _context.PatientContact
|
||||
.FirstOrDefaultAsync(x => x.Id == request.Data.Id, cancellationToken);
|
||||
|
||||
if (entity == null)
|
||||
{
|
||||
return new UpdatePatientContactResponse
|
||||
{
|
||||
Id = request.Data.Id,
|
||||
Success = false
|
||||
};
|
||||
}
|
||||
|
||||
entity.Name = request.Data.Name;
|
||||
entity.Title = request.Data.Title;
|
||||
entity.PhoneNumber = request.Data.PhoneNumber;
|
||||
entity.EmailAddress = request.Data.EmailAddress;
|
||||
entity.Description = request.Data.Description;
|
||||
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return new UpdatePatientContactResponse
|
||||
{
|
||||
Id = entity.Id,
|
||||
Success = true
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
using Indotalent.ConfigBackEnd.Exceptions;
|
||||
using Indotalent.Infrastructure.Database;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Indotalent.Features.Thirdparty.Patient.Cqrs;
|
||||
|
||||
public class UpdatePatientRequest
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? Street { get; set; }
|
||||
public string? City { get; set; }
|
||||
public string? State { get; set; }
|
||||
public string? ZipCode { get; set; }
|
||||
public string? Country { get; set; }
|
||||
public string? PhoneNumber { get; set; }
|
||||
public string? FaxNumber { get; set; }
|
||||
public string? EmailAddress { get; set; }
|
||||
public string? Website { get; set; }
|
||||
public string? WhatsApp { get; set; }
|
||||
public string? LinkedIn { get; set; }
|
||||
public string? Facebook { get; set; }
|
||||
public string? Instagram { get; set; }
|
||||
public string? TwitterX { get; set; }
|
||||
public string? TikTok { get; set; }
|
||||
public string? PatientGroupId { get; set; }
|
||||
public string? PatientCategoryId { get; set; }
|
||||
public DateTimeOffset? CreatedAt { get; set; }
|
||||
public string? CreatedBy { get; set; }
|
||||
public DateTimeOffset? UpdatedAt { get; set; }
|
||||
public string? UpdatedBy { get; set; }
|
||||
}
|
||||
|
||||
public class UpdatePatientResponse
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public bool Success { get; set; }
|
||||
}
|
||||
|
||||
public record UpdatePatientCommand(UpdatePatientRequest Data) : IRequest<UpdatePatientResponse>;
|
||||
|
||||
public class UpdatePatientHandler : IRequestHandler<UpdatePatientCommand, UpdatePatientResponse>
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public UpdatePatientHandler(AppDbContext context) => _context = context;
|
||||
|
||||
public async Task<UpdatePatientResponse> Handle(UpdatePatientCommand request, CancellationToken cancellationToken)
|
||||
{
|
||||
var isExists = await _context.Patient
|
||||
.AnyAsync(x => x.Name == request.Data.Name && x.Id != request.Data.Id, cancellationToken);
|
||||
|
||||
if (isExists)
|
||||
{
|
||||
throw new AlreadyExistsException("Patient", request.Data.Name ?? string.Empty);
|
||||
}
|
||||
|
||||
var entity = await _context.Patient
|
||||
.FirstOrDefaultAsync(x => x.Id == request.Data.Id, cancellationToken);
|
||||
|
||||
if (entity == null)
|
||||
{
|
||||
return new UpdatePatientResponse { Id = request.Data.Id, Success = false };
|
||||
}
|
||||
|
||||
entity.Name = request.Data.Name;
|
||||
entity.Description = request.Data.Description;
|
||||
entity.Street = request.Data.Street;
|
||||
entity.City = request.Data.City;
|
||||
entity.State = request.Data.State;
|
||||
entity.ZipCode = request.Data.ZipCode;
|
||||
entity.Country = request.Data.Country;
|
||||
entity.PhoneNumber = request.Data.PhoneNumber;
|
||||
entity.FaxNumber = request.Data.FaxNumber;
|
||||
entity.EmailAddress = request.Data.EmailAddress;
|
||||
entity.Website = request.Data.Website;
|
||||
entity.WhatsApp = request.Data.WhatsApp;
|
||||
entity.LinkedIn = request.Data.LinkedIn;
|
||||
entity.Facebook = request.Data.Facebook;
|
||||
entity.Instagram = request.Data.Instagram;
|
||||
entity.TwitterX = request.Data.TwitterX;
|
||||
entity.TikTok = request.Data.TikTok;
|
||||
entity.PatientGroupId = request.Data.PatientGroupId;
|
||||
entity.PatientCategoryId = request.Data.PatientCategoryId;
|
||||
|
||||
await _context.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return new UpdatePatientResponse
|
||||
{
|
||||
Id = entity.Id,
|
||||
Success = true
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using FluentValidation;
|
||||
using Indotalent.Shared.Consts;
|
||||
|
||||
namespace Indotalent.Features.Thirdparty.Patient.Cqrs;
|
||||
|
||||
public class UpdatePatientValidator : AbstractValidator<UpdatePatientRequest>
|
||||
{
|
||||
public UpdatePatientValidator()
|
||||
{
|
||||
RuleFor(x => x.Id)
|
||||
.NotEmpty().WithMessage("ID is required for update");
|
||||
|
||||
RuleFor(x => x.Name)
|
||||
.NotEmpty().WithMessage("Patient Name is required")
|
||||
.MaximumLength(GlobalConsts.StringLengthShort);
|
||||
|
||||
RuleFor(x => x.EmailAddress)
|
||||
.EmailAddress().When(x => !string.IsNullOrEmpty(x.EmailAddress));
|
||||
|
||||
RuleFor(x => x.PatientGroupId)
|
||||
.NotEmpty().WithMessage("Patient Group is required");
|
||||
|
||||
RuleFor(x => x.PatientCategoryId)
|
||||
.NotEmpty().WithMessage("Patient Category is required");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user