-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from lucasdaquina/feat/create-new-medication
Feat/create new medication
- Loading branch information
Showing
8 changed files
with
156 additions
and
9 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
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,17 @@ | ||
using Azure.Core; | ||
|
||
namespace SM.Medication.Api.Extensions; | ||
|
||
public static class StringExtensions | ||
{ | ||
public static void GuardString(this string? value, string nameOf) | ||
{ | ||
ArgumentNullException.ThrowIfNull(value, nameOf); | ||
|
||
if(string.IsNullOrEmpty(value)) | ||
throw new Exception($"{nameOf} cannot be null or empty"); | ||
|
||
if(string.IsNullOrWhiteSpace(value)) | ||
throw new Exception($"{nameOf} cannot be empty or whitespace"); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/SM.Medication.Application/Commands/CreateMedicationCommand.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,14 @@ | ||
using System.ComponentModel; | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace SM.Medication.Application.Commands; | ||
|
||
public class CreateMedicationCommand | ||
{ | ||
[Required] | ||
public string? Name { get; set; } | ||
[Required] | ||
[DefaultValue(1)] | ||
[Range(1, int.MaxValue)] | ||
public int Quantity { 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
3 changes: 3 additions & 0 deletions
3
src/SM.Medication.Application/Interfaces/IMedicationHandler.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 |
---|---|---|
@@ -1,5 +1,8 @@ | ||
using SM.Medication.Application.Commands; | ||
|
||
namespace SM.Medication.Application.Interfaces; | ||
public interface IMedicationHandler | ||
{ | ||
Task<List<MedicationDTO>> Handle(); | ||
Task<bool> Handle(CreateMedicationCommand command); | ||
} |
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 |
---|---|---|
@@ -1,6 +1,9 @@ | ||
|
||
namespace SM.Medication.Domain.Interfaces; | ||
|
||
public interface IMedicationRepository | ||
{ | ||
Task<bool> Add(Entities.Medication entity); | ||
Task<List<Domain.Entities.Medication>> GetAll(); | ||
Task<Domain.Entities.Medication?> GetByName(string name); | ||
} |
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