Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #1

Open
wants to merge 27 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0b9fc0a
Setting up GitHub Classroom Feedback
github-classroom[bot] Mar 18, 2021
4d3c96e
First draft documentation
Cimeiesh Mar 18, 2021
7bdb1d9
commit
isakKavallin Mar 18, 2021
43c62a1
Merge branch 'main' of https://github.com/PGVSNH20/spacepark-grupp-5 …
isakKavallin Mar 18, 2021
e6e3ea2
Person class, api requests
hampussle Mar 18, 2021
3536e8e
API Test
hampussle Mar 19, 2021
08fac39
Entity Framwork initial commit
hampussle Mar 22, 2021
db06e86
Add GetShips-method
amandaalmgren Mar 23, 2021
64511b0
Finish GetShip
Cimeiesh Mar 24, 2021
c0f917e
Add SpaceApp
Cimeiesh Mar 25, 2021
e931257
Space park UI
Cimeiesh Mar 25, 2021
a6b2ec8
Moved everything to SpaceApp
Cimeiesh Mar 26, 2021
2d30fa5
Add-Migration SpaceApp
Cimeiesh Mar 26, 2021
8f4c5a7
SpaceApp Update
Cimeiesh Mar 26, 2021
d8919a6
form update, wpf add
hampussle Mar 29, 2021
6530736
timer add
hampussle Mar 29, 2021
888ff7a
current time add
hampussle Mar 29, 2021
802c716
added park button
isakKavallin Mar 29, 2021
728ed56
Revert "added park button"
isakKavallin Mar 29, 2021
004bda2
commit
isakKavallin Mar 29, 2021
9de7e2f
Merge branch 'main' of https://github.com/PGVSNH20/spacepark-grupp-5 …
isakKavallin Mar 29, 2021
931b073
forms
isakKavallin Mar 29, 2021
0221e16
fix
isakKavallin Mar 29, 2021
44cbdbd
parking timer updated
hampussle Mar 29, 2021
ef568f9
Merge branch 'main' of https://github.com/PGVSNH20/spacepark-grupp-5 …
hampussle Mar 29, 2021
2fb6b15
some fixes & database add
hampussle Mar 29, 2021
dae722e
tests & cleanup
hampussle Mar 29, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,4 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/
/Source/SpaceAppWPF/Resources/spacepark.jpg
22 changes: 21 additions & 1 deletion Documentation/readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
# Documentation

Use this file to fill in your documentation
# 2021 18 Mars
--------------

## Vad ska programmet göra?
------------------------
* Mata in namn och skepp
* Parkeringen skall registrera i databasen
* Skall betala när de lämnar
* Se till att Namn och skepptyp finns i swapi.dev > som ska hämta en lista av skepp
* Tid lagras i databasen för att se hur länge när man använder parkeringen för att få rätt pris
* Glöm inte test (om det är möjligt)

## UX
-------------------------
* Språk: Engelska
* Valuta: Credits

## Ordning
------------------------
* Installera RestSharp
* Göra ett test request
* Göra asynkron för API
55 changes: 55 additions & 0 deletions Source/SpaceApp.Tests/ApiTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using SpacePark;
using System;
using Xunit;

namespace SpaceApp.Tests
{
public class ApiTests
{
Rest starwars = new Rest();

[Fact]
public async void ApiReturnsResponse()
{
var response = await starwars.StarWarsApiRequestAsync("people/?search=r2");

Assert.True(response.IsSuccessful);
}

[Fact]
public async void ApiReturnsCorrectResponse()
{
var response = await starwars.StarWarsApiRequestAsync("people/?search=r2");
var person = starwars.Deserialize<dynamic>(response);
var results = person["results"][0];

Assert.Equal("R2-D2", results["name"]);
}
}

public class DbTests
{

}

public class SearchTests
{

}

public class SelectionTests
{

}
}

/*

The user entering his name
Making a simple request against the Starwars Web API to all persons
Check the name the user entered against the persons from the API request
Creating a simple table in the database using Entity Framework
Store in the database that the user have registered himself
List in the UI all registrations which have been done so far

*/
26 changes: 26 additions & 0 deletions Source/SpaceApp.Tests/SpaceApp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0-windows</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.3.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\SpaceApp\SpaceApp.csproj" />
</ItemGroup>

</Project>
62 changes: 62 additions & 0 deletions Source/SpaceApp/Database.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.Threading.Tasks;

namespace SpacePark
{
public class Database
{
private static async Task StorePersonInDatabase(dynamic person, int personId)
{
//lägg till om den inte finns
await Task.Run(() => {
SpaceParkContext db = new SpaceParkContext();
var personQuery = db.Person.Find(personId);
if (personQuery == null)
{
var Person = new Person() { Name = person["name"], PersonId = personId };
db.Person.Add(Person);
db.SaveChanges();
}
});
}

private static async Task StoreStarShipInDatabase(dynamic starship, int starshipId)
{
//lägg till om den inte finns
await Task.Run(() => {
SpaceParkContext db = new SpaceParkContext();
var starShipQuery = db.StarShip.Find(starshipId);
if (starShipQuery == null)
{
StarShip starShip = new StarShip() { StarShipName = starship["name"], StarShipId = starshipId };
db.StarShip.Add(starShip);
db.SaveChanges();
}
});
}

public static async void StoreParking(dynamic person, dynamic starship, int time, int price)
{
SpaceParkContext db = new SpaceParkContext();
db.Database.EnsureCreated();

//primary key blir till siffran från swapi url
var starshipId = Int32.Parse(starship["url"].Remove(0, 31).Trim('/'));
var personId = Int32.Parse(person["url"].Remove(0, 28).Trim('/'));

Task persontask = StorePersonInDatabase(person, personId);
Task starshiptask = StoreStarShipInDatabase(starship, starshipId);

var park = new ParkEvent() {
StarShipId = starshipId,
PersonId = personId,
TimeParked = time.ToString(),
Price = price
};
db.ParkEvent.Add(park);

await Task.WhenAll(persontask, starshiptask);
db.SaveChanges();
}
}
}
183 changes: 183 additions & 0 deletions Source/SpaceApp/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading