diff --git a/OFBButte.Api/Controllers/MissionaryController.cs b/OFBButte.Api/Controllers/MissionaryController.cs new file mode 100644 index 0000000..2a9322c --- /dev/null +++ b/OFBButte.Api/Controllers/MissionaryController.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Options; +using OFBButte.Application.Configuration; +using OFBButte.Application.Database; +using OFBButte.Application.Missionary; +using OFBButte.Entities; + +namespace OFBButte.Api.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class MissionaryController : ControllerBase + { + private readonly AppSettings appSettings; + private readonly IOFBContext context; + public MissionaryController(IOptions options, IOFBContext context) + { + this.appSettings = options.Value; + this.context = context; + } + + [HttpPost] + public ActionResult Post([FromBody] MissionarySupport value) + { + var adder = new AddMissionarySupportForm(context); + var result = adder.Handle(value); + return result; + } + + [HttpGet("{id}")] + public ActionResult Get(int id) + { + throw new NotImplementedException(); + var getter = new GetMissionarySupportForm(context); + var result = getter.Handle(id); + return result; + } + + + } +} \ No newline at end of file diff --git a/OFBButte.Api/OFBButte.Api.csproj b/OFBButte.Api/OFBButte.Api.csproj index d1ad426..4b1434a 100644 --- a/OFBButte.Api/OFBButte.Api.csproj +++ b/OFBButte.Api/OFBButte.Api.csproj @@ -5,9 +5,20 @@ InProcess + + + + + + + MSBuild:Compile + + + + diff --git a/OFBButte.Api/appsettings.Development.json b/OFBButte.Api/appsettings.Development.json index 63f6029..f67631e 100644 --- a/OFBButte.Api/appsettings.Development.json +++ b/OFBButte.Api/appsettings.Development.json @@ -10,6 +10,6 @@ "Environment": "Dev" }, "ConnectionStrings": { - "OFBContext": "server=localhost;database=ofbtest;user=ofbapi;password=87hjdusiodksyeunsjkdis7" + "OFBContext": "server=localhost;database=ofb2_test;user=ofbapi2_test;password=Look to the LORD and his strength seek his face always" } } diff --git a/OFBButte.Api/appsettings.Production.json b/OFBButte.Api/appsettings.Production.json new file mode 100644 index 0000000..8319c1d --- /dev/null +++ b/OFBButte.Api/appsettings.Production.json @@ -0,0 +1,8 @@ +{ + "App": { + "Environment": "Prod" + }, + "ConnectionStrings": { + "OFBContext": "server=localhost;database=ofb2;user=ofbapi2;password=Set your minds on things above not on earthly things;" + } +} diff --git a/OFBButte.Api/missionary_sample.json b/OFBButte.Api/missionary_sample.json new file mode 100644 index 0000000..07f1283 --- /dev/null +++ b/OFBButte.Api/missionary_sample.json @@ -0,0 +1,81 @@ +{ + "id": 0, + "name": "John Smith", + "homePhone": "4063330989", + "cellPhone": "4068749384", + "fieldPhone": "28398736", + "wifesName": "Cathy Smith", + "children": [ + { + "id": 0, + "name": "Michael Smith" + }, + { + "id": 1, + "name": "Melanie Smith" + } + ], + "testimony": "The testimony of how I got saved", + "callToField": "my call to the field", + "sendingChurch": "Sent by Old Fashion Baptist Church", + "fieldOfService": "My field of service", + "plans": "Start churches and train national pastors", + "evaluationOfNationals": "Very receptive to the Word of God", + "timeInCountry": "2 years", + "correctWrongOfAnotherMissionary": "Prayer and support", + "financialStatementPrevYear": "28,000", + "currentMonthlySupport": 1000, + "monthlySupportNeeded": 2000, + "restAndRelaxation": "Once a week", + "aloneOrTeam": "Alone", + "childrenSchool": 0, + "dance": false, + "worldlyMusic": false, + "movieTheaters": false, + "alcohol": false, + "smoking": false, + "maleHair": false, + "femaleSlacks": 0, + "femaleShorts": 0, + "femaleDressStandard": false, + "swimmingClothing": null, + "television": null, + "dailyBible": 0, + "numberLedToChrist": 0.0, + "numberWitnessedTo": 0.0, + "numberWeeklyTracts": 0.0, + "rateOfSuccess": "Somewhat successful", + "predestination": "All have the choice to accept or reject Jesus Chris", + "fellowshipAssociation": "None", + "collegeRecommendations": [ + { + "id": 0, + "name": "Pensacola Christian College" + }, + { + "id": 1, + "name": "Bible Baptist University" + }, + { + "id": 2, + "name": "Bible School" + } + ], + "admittedWrong": "All the time", + "divorced": false, + "groundsForRemarry": false, + "marryADivorcee": false, + "masonicLodge": false, + "bibleVersionsUsed": "KVJ", + "bibleVersionOpinion": "KJV is for the english speaking people", + "contemporaryMusic": false, + "charasmaticism": "Do not agree with it", + "tongues": false, + "repentanceNecessary": true, + "repentanceDefinition": "Change of heart towards sin", + "fundamentalist": false, + "billsOnTime": "Never been late", + "lateBills": "NA", + "lateBillActionTaken": "NA", + "potentialHarvest": "The harvest is plentyous" +} diff --git a/OFBButte.Application/Missionary/AddMissionarySupportForm.cs b/OFBButte.Application/Missionary/AddMissionarySupportForm.cs index 7f79a53..9fb9135 100644 --- a/OFBButte.Application/Missionary/AddMissionarySupportForm.cs +++ b/OFBButte.Application/Missionary/AddMissionarySupportForm.cs @@ -17,6 +17,14 @@ namespace OFBButte.Application.Missionary public MissionarySupport Handle(MissionarySupport support) { support.Id = 0; + foreach (var child in support.Children) + { + child.Id = 0; + } + foreach(var school in support.CollegeRecommendations) + { + school.Id = 0; + } context.MissionarySupportForms.Add(support); context.SaveChanges(); return support; diff --git a/OFBButte.Application/Missionary/GetMissionarySupportForm.cs b/OFBButte.Application/Missionary/GetMissionarySupportForm.cs index cd2eba6..8e2992c 100644 --- a/OFBButte.Application/Missionary/GetMissionarySupportForm.cs +++ b/OFBButte.Application/Missionary/GetMissionarySupportForm.cs @@ -1,4 +1,5 @@ -using OFBButte.Application.Database; +using Microsoft.EntityFrameworkCore; +using OFBButte.Application.Database; using OFBButte.Entities; using System; using System.Collections.Generic; @@ -17,7 +18,10 @@ namespace OFBButte.Application.Missionary public MissionarySupport Handle(int id) { - return context.MissionarySupportForms.FirstOrDefault(m => m.Id == id); + return context.MissionarySupportForms + .Include(m => m.Children) + .Include(m => m.CollegeRecommendations) + .FirstOrDefault(m => m.Id == id); } } } diff --git a/OFBButte.Entities/MissionarySupport.cs b/OFBButte.Entities/MissionarySupport.cs index f711a94..6e37f5d 100644 --- a/OFBButte.Entities/MissionarySupport.cs +++ b/OFBButte.Entities/MissionarySupport.cs @@ -12,7 +12,7 @@ namespace OFBButte.Entities public string CellPhone { get; set; } public string FieldPhone { get; set; } public string WifesName { get; set; } - public MissionaryChild[] Children { get; set; } + public ICollection Children { get; set; } public string Testimony { get; set; } public string CallToField { get; set; } public string SendingChurch { get; set; } @@ -45,7 +45,7 @@ namespace OFBButte.Entities public string RateOfSuccess { get; set; } public string Predestination { get; set; } public string FellowshipAssociation { get; set; } - public MissionaryCollegeRecommendation[] CollegeRecommendations { get; set; } + public ICollection CollegeRecommendations { get; set; } public string AdmittedWrong { get; set; } public bool Divorced { get; set; } public bool GroundsForRemarry { get; set; }