20 lines
841 B
C#
20 lines
841 B
C#
using Brizco.Domain.Entities.Tasks;
|
|
|
|
namespace Brizco.Core.EntityServices.Handlers.Activities;
|
|
|
|
public class DoneActivityCommandHandler(IRepositoryWrapper repositoryWrapper) : IRequestHandler<DoneActivityCommand,bool>
|
|
{
|
|
public async Task<bool> Handle(DoneActivityCommand request, CancellationToken cancellationToken)
|
|
{
|
|
var activity = await repositoryWrapper.SetRepository<Activity>()
|
|
.TableNoTracking
|
|
.FirstOrDefaultAsync(a => a.Id == request.Id, cancellationToken);
|
|
if (activity == null)
|
|
throw new AppException("Activity not found", ApiResultStatusCode.NotFound);
|
|
activity.DoneActivity();
|
|
repositoryWrapper.SetRepository<Activity>()
|
|
.Update(activity);
|
|
await repositoryWrapper.SaveChangesAsync(cancellationToken);
|
|
return true;
|
|
}
|
|
} |