Ajout de l'action d'ajout de saut.
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
|
||||||
using skydiveLogs_api.Business.Interface;
|
using skydiveLogs_api.Business.Interface;
|
||||||
using skydiveLogs_api.Model;
|
using skydiveLogs_api.Model;
|
||||||
using skydiveLogs_api.Data.Interface;
|
using skydiveLogs_api.Data.Interface;
|
||||||
|
|
||||||
|
|
||||||
namespace skydiveLogs_api.Business
|
namespace skydiveLogs_api.Business
|
||||||
{
|
{
|
||||||
public class JumpService : IJumpService
|
public class JumpService : IJumpService
|
||||||
@@ -16,7 +17,7 @@ namespace skydiveLogs_api.Business
|
|||||||
|
|
||||||
public void AddNewJump(Jump jump)
|
public void AddNewJump(Jump jump)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
_jumpRepository.AddJump(jump);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteJumpById(int id)
|
public void DeleteJumpById(int id)
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using skydiveLogs_api.Model;
|
using skydiveLogs_api.Model;
|
||||||
|
|
||||||
namespace skydiveLogs_api.Data.Interface
|
namespace skydiveLogs_api.Data.Interface
|
||||||
@@ -10,5 +8,7 @@ namespace skydiveLogs_api.Data.Interface
|
|||||||
IEnumerable<Jump> GetAllJumps();
|
IEnumerable<Jump> GetAllJumps();
|
||||||
|
|
||||||
Jump GetJumpById(int id);
|
Jump GetJumpById(int id);
|
||||||
|
|
||||||
|
bool AddJump(Jump newJump);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,5 +38,33 @@ namespace skydiveLogs_api.Data
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool AddJump(Jump newJump)
|
||||||
|
{
|
||||||
|
var result = true;
|
||||||
|
List<Jump> jumpList;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (StreamReader file = File.OpenText(@"Data/Jump.json"))
|
||||||
|
using (JsonTextReader reader = new JsonTextReader(file))
|
||||||
|
{
|
||||||
|
var jsonResult = (JArray)JToken.ReadFrom(reader);
|
||||||
|
jumpList = jsonResult.ToObject<List<Jump>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
newJump.Id = jumpList.Count() + 1;
|
||||||
|
jumpList.Add(newJump);
|
||||||
|
|
||||||
|
string outputJson = JsonConvert.SerializeObject(jumpList);
|
||||||
|
File.WriteAllText(@"Data/Jump.json", outputJson);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1 @@
|
|||||||
[
|
[{"Id":1,"JumpTypeId":1,"AircraftId":5,"DropZoneId":6,"GearId":8,"ExitAltitude":40001,"DeployAltitude":10002,"WithCutaway":true,"Notes":"","JumpDate":"0001-01-01T00:00:00"},{"Id":2,"JumpTypeId":1,"AircraftId":5,"DropZoneId":6,"GearId":8,"ExitAltitude":40001,"DeployAltitude":10002,"WithCutaway":true,"Notes":"","JumpDate":"0001-01-01T00:00:00"}]
|
||||||
{
|
|
||||||
"id": 1,
|
|
||||||
"jumpTypeId" : 1,
|
|
||||||
"aircraftId" : 1,
|
|
||||||
"dropZoneId" : 1,
|
|
||||||
"gearId" : 1,
|
|
||||||
"exitAltitude" : "4000",
|
|
||||||
"deployAltitude" : "1500",
|
|
||||||
"withCutaway" : false,
|
|
||||||
"notes" : ""
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -7,5 +7,24 @@ namespace skydiveLogs_api.DataContract
|
|||||||
{
|
{
|
||||||
public class JumpReq
|
public class JumpReq
|
||||||
{
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public int JumpTypeId { get; set; }
|
||||||
|
|
||||||
|
public int AircraftId { get; set; }
|
||||||
|
|
||||||
|
public int DropZoneId { get; set; }
|
||||||
|
|
||||||
|
public int GearId { get; set; }
|
||||||
|
|
||||||
|
public int ExitAltitude { get; set; }
|
||||||
|
|
||||||
|
public int DeployAltitude { get; set; }
|
||||||
|
|
||||||
|
public bool WithCutaway { get; set; }
|
||||||
|
|
||||||
|
public string Notes { get; set; }
|
||||||
|
|
||||||
|
public DateTime JumpDate { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"windowsAuthentication": false,
|
"windowsAuthentication": false,
|
||||||
"anonymousAuthentication": true,
|
"anonymousAuthentication": true,
|
||||||
"iisExpress": {
|
"iisExpress": {
|
||||||
"applicationUrl": "http://localhost:51376",
|
"applicationUrl": "http://localhost:5000",
|
||||||
"sslPort": 0
|
"sslPort": 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user