-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add stepComplete mutation with mocked data (#52)
- Loading branch information
1 parent
6e7d3e9
commit a464730
Showing
12 changed files
with
277 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
TeacherWorkout.Api/GraphQL/Types/Inputs/StepCompleteInputType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using GraphQL.Types; | ||
using TeacherWorkout.Domain.Models.Inputs; | ||
|
||
namespace TeacherWorkout.Api.GraphQL.Types.Inputs | ||
{ | ||
public class StepCompleteInputType : InputObjectGraphType<StepCompleteInput> | ||
{ | ||
public StepCompleteInputType() | ||
{ | ||
Name = "StepCompleteInput"; | ||
|
||
Field(x => x.StepId, type: typeof(NonNullGraphType<IdGraphType>)); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
TeacherWorkout.Api/GraphQL/Types/Payloads/StepCompletePayloadType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using GraphQL.Types; | ||
using TeacherWorkout.Domain.Models.Payloads; | ||
|
||
namespace TeacherWorkout.Api.GraphQL.Types.Payloads | ||
{ | ||
public class StepCompletePayloadType : ObjectGraphType<StepCompletePayload> | ||
{ | ||
public StepCompletePayloadType() | ||
{ | ||
Name = "StepCompletePayload"; | ||
|
||
Field(x => x.Step, type: typeof(StepUnionType)).Description("The completed step."); | ||
Field(x => x.LessonStatus).Description("The status of the lesson."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using TeacherWorkout.Domain.Common; | ||
using TeacherWorkout.Domain.Models; | ||
using TeacherWorkout.Domain.Models.Inputs; | ||
using TeacherWorkout.Domain.Models.Payloads; | ||
|
||
namespace TeacherWorkout.Domain.Lessons | ||
{ | ||
public class CompleteStep : IOperation<StepCompleteInput, StepCompletePayload> | ||
{ | ||
private readonly IStepRepository _stepRepository; | ||
private readonly ILessonStatusRepository _lessonStatusRepository; | ||
|
||
public CompleteStep(IStepRepository stepRepository, ILessonStatusRepository lessonStatusRepository) | ||
{ | ||
_stepRepository = stepRepository; | ||
_lessonStatusRepository = lessonStatusRepository; | ||
} | ||
|
||
public StepCompletePayload Execute(StepCompleteInput input) | ||
{ | ||
var step = _stepRepository.CompleteStep(input.StepId); | ||
var lessonId = (step.GetType().GetProperty("Lesson").GetValue(step) as Lesson).Id; | ||
|
||
var lessonStatus = _lessonStatusRepository | ||
.List( | ||
new LessonStatusFilter() | ||
{ | ||
LessonIds = new List<string>() { lessonId } | ||
}) | ||
.FirstOrDefault(); | ||
|
||
return new StepCompletePayload() | ||
{ | ||
Step = step, | ||
LessonStatus = lessonStatus | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
using TeacherWorkout.Domain.Models; | ||
using TeacherWorkout.Domain.Models.Payloads; | ||
|
||
namespace TeacherWorkout.Domain.Lessons | ||
{ | ||
public interface IStepRepository | ||
{ | ||
ILessonStep Find(string id); | ||
|
||
ILessonStep CompleteStep(string id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace TeacherWorkout.Domain.Models.Inputs | ||
{ | ||
public class StepCompleteInput | ||
{ | ||
public string StepId { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace TeacherWorkout.Domain.Models.Payloads | ||
{ | ||
public class StepCompletePayload | ||
{ | ||
public ILessonStep Step { get; set; } | ||
|
||
public LessonStatus LessonStatus { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters