public async Task <Unit> Handle(UpdateModuleCommand command, CancellationToken token) { var moduleToUpdate = await _commonService.GetModuleFromRepo(command.ModuleId, token); _commonService.CheckCourseStatusForModification(moduleToUpdate); _service.UpdateModuleName(moduleToUpdate, command.Name); _service.UpdateModuleRepo(moduleToUpdate); await _unitOfWork.SaveAsync(token); return(Unit.Value); }
public async Task <Unit> Handle(UpdateLecturesOrdersCommand command, CancellationToken token) { var module = await _commonService.GetModuleFromRepo(command.ModuleId, token); _commonService.CheckCourseStatusForModification(module); var lecturesToUpdateOrders = await _service.GetModuleLecturesFromRepo(command.ModuleId, token); _service.UpdateLecturesOrders(lecturesToUpdateOrders, command.LecturesOrders); _service.UpdateLecturesRepo(lecturesToUpdateOrders); await _unitOfWork.SaveAsync(token); return(Unit.Value); }
public async Task <CommandResponse> Handle(DeleteModuleCommand command, CancellationToken token) { var moduleToDelete = await _commonService.GetModuleFromRepo(command.ModuleId, token); _commonService.CheckCourseStatusForModification(moduleToDelete); _service.RemoveModuleFromRepo(moduleToDelete); await _unitOfWork.SaveAsync(token); await _mediator.Publish(new ModuleDeletedEvent(moduleToDelete.Id), token); return(new CommandResponse { Value = moduleToDelete.Id }); }