Fix about the favorite DZ
This commit is contained in:
10
.gitignore
vendored
10
.gitignore
vendored
@@ -32,8 +32,8 @@
|
|||||||
/Back/skydiveLogs-api.Domain/obj
|
/Back/skydiveLogs-api.Domain/obj
|
||||||
/Back/skydiveLogs-api.Domain/bin/Debug/net5.0
|
/Back/skydiveLogs-api.Domain/bin/Debug/net5.0
|
||||||
/Back/skydiveLogs-api.Data/bin/Debug/net5.0
|
/Back/skydiveLogs-api.Data/bin/Debug/net5.0
|
||||||
Back/skydiveLogs-api.Domain/bin/Release/net5.0/ref/skydiveLogs-api.Domain.dll
|
/Back/skydiveLogs-api.Domain/bin/Release/net5.0/ref/skydiveLogs-api.Domain.dll
|
||||||
Back/skydiveLogs-api.Domain/bin/Release/net5.0/skydiveLogs-api.Domain.dll
|
/Back/skydiveLogs-api.Domain/bin/Release/net5.0/skydiveLogs-api.Domain.dll
|
||||||
Back/skydiveLogs-api.Domain/bin/Release/net5.0/skydiveLogs-api.Domain.pdb
|
/Back/skydiveLogs-api.Domain/bin/Release/net5.0/skydiveLogs-api.Domain.pdb
|
||||||
Back/skydiveLogs-api/Data/JumpsDb-log.db
|
/Back/skydiveLogs-api/Data/JumpsDb-log.db
|
||||||
Back/skydiveLogs-api/Data/JumpsDb.db
|
/Back/skydiveLogs-api/Data/JumpsDb.db
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
{
|
{
|
||||||
public class FavoriteDropZone
|
public class FavoriteDropZone
|
||||||
{
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
public DropZone DropZone { get; set; }
|
public DropZone DropZone { get; set; }
|
||||||
|
|
||||||
public User User { get; set; }
|
public User User { get; set; }
|
||||||
|
|||||||
@@ -30,13 +30,12 @@ namespace skydiveLogs_api.DomainBusiness
|
|||||||
public IEnumerable<DropZone> GetAllDzs(User connectedUser)
|
public IEnumerable<DropZone> GetAllDzs(User connectedUser)
|
||||||
{
|
{
|
||||||
var results = Enumerable.Empty<DropZone>();
|
var results = Enumerable.Empty<DropZone>();
|
||||||
|
|
||||||
var dropzones = _dropZoneRepository.GetAll();
|
var dropzones = _dropZoneRepository.GetAll();
|
||||||
var favorites = _favoriteDropZoneRepository.GetAll(connectedUser);
|
var favorites = _favoriteDropZoneRepository.GetAll(connectedUser);
|
||||||
|
|
||||||
|
|
||||||
results = from dropZone in dropzones
|
results = from dropZone in dropzones
|
||||||
join favorite in favorites on dropZone equals favorite.DropZone into tmp
|
join favorite in favorites on dropZone.Id equals favorite.DropZone.Id into tmp
|
||||||
from favoriteDz in tmp.DefaultIfEmpty()
|
from favoriteDz in tmp.DefaultIfEmpty()
|
||||||
select new DropZone
|
select new DropZone
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ namespace skydiveLogs_api.Ioc
|
|||||||
_services.AddScoped<IGearRepository, GearRepository>();
|
_services.AddScoped<IGearRepository, GearRepository>();
|
||||||
_services.AddScoped<IUserRepository, UserRepository>();
|
_services.AddScoped<IUserRepository, UserRepository>();
|
||||||
_services.AddScoped<IUserImageRepository, UserImageRepository>();
|
_services.AddScoped<IUserImageRepository, UserImageRepository>();
|
||||||
|
_services.AddScoped<IFavoriteDropZoneRepository, FavoriteDropZoneRepository>();
|
||||||
|
|
||||||
string connectionString = _configuration.GetConnectionString("DefaultConnection");
|
string connectionString = _configuration.GetConnectionString("DefaultConnection");
|
||||||
_services.AddSingleton<IDataProvider>(c => new LiteDbProvider(connectionString));
|
_services.AddSingleton<IDataProvider>(c => new LiteDbProvider(connectionString));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ namespace skydiveLogs_api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PUT: api/DropZone/AddToFavorite/5
|
// PUT: api/DropZone/AddToFavorite/5
|
||||||
[HttpPut("{id}")]
|
[HttpPut("AddToFavorite/{id}")]
|
||||||
[EnableCors]
|
[EnableCors]
|
||||||
public bool AddToFavorite(int id)
|
public bool AddToFavorite(int id)
|
||||||
{
|
{
|
||||||
@@ -73,7 +73,7 @@ namespace skydiveLogs_api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// PUT: api/DropZone/RemoveToFavorite/15
|
// PUT: api/DropZone/RemoveToFavorite/15
|
||||||
[HttpPut("{id}")]
|
[HttpPut("RemoveToFavorite/{id}")]
|
||||||
[EnableCors]
|
[EnableCors]
|
||||||
public bool RemoveToFavorite(int id)
|
public bool RemoveToFavorite(int id)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ namespace skydiveLogs_api.Controllers
|
|||||||
_jumpService.UpdateJump(id, _mapper.Map<Jump>(value));
|
_jumpService.UpdateJump(id, _mapper.Map<Jump>(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
// DELETE: api/ApiWithActions/5
|
// DELETE: api/Jump/5
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
[EnableCors]
|
[EnableCors]
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ namespace skydiveLogs_api.Controllers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GET: api/User/AlwayLogin
|
// GET: api/User/AlwayLogin
|
||||||
[HttpGet("AlwayLogin")]
|
[HttpGet("AlwaysLogin")]
|
||||||
[EnableCors]
|
[EnableCors]
|
||||||
public IActionResult AlwayLogin()
|
public IActionResult AlwaysLogin()
|
||||||
{
|
{
|
||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<WebStackScaffolding_IsAsyncSelected>False</WebStackScaffolding_IsAsyncSelected>
|
<WebStackScaffolding_IsAsyncSelected>False</WebStackScaffolding_IsAsyncSelected>
|
||||||
<NameOfLastUsedPublishProfile>C:\Projects\SkydiveLogs\Back\skydiveLogs-api\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
|
<NameOfLastUsedPublishProfile>C:\Projects\SkydiveLogs\Back\skydiveLogs-api\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
|
||||||
<ShowAllFiles>false</ShowAllFiles>
|
<ShowAllFiles>false</ShowAllFiles>
|
||||||
<ActiveDebugProfile>skydiveLogs_api</ActiveDebugProfile>
|
<ActiveDebugProfile>IIS Express</ActiveDebugProfile>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||||
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
|
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
|
||||||
|
|||||||
@@ -72,9 +72,9 @@ export class AuthenticationService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private alwaysLogin() {
|
private alwaysLogin() {
|
||||||
return this.http.get(`${this.apiUrl}/User/AlwayLogin`, {
|
return this.http.get(`${this.apiUrl}/User/AlwaysLogin`, {
|
||||||
headers: this.headers
|
headers: this.headers
|
||||||
});
|
}).subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
logout() {
|
logout() {
|
||||||
|
|||||||
@@ -14,50 +14,42 @@ export class DropzoneService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public getListOfDropZones(): Observable<Array<DropZoneResp>> {
|
public getListOfDropZones(): Observable<Array<DropZoneResp>> {
|
||||||
return this.http
|
return this.http.get<Array<DropZoneResp>>(`${this.apiUrl}/DropZone`,
|
||||||
.get<Array<DropZoneResp>>(`${this.apiUrl}/DropZone`, {
|
{ headers: this.headers })
|
||||||
headers: this.headers
|
.pipe(map(response => {
|
||||||
})
|
const details = response.map(data => new DropZoneResp(data));
|
||||||
.pipe(
|
return details;
|
||||||
map(response => {
|
}));
|
||||||
const details = response.map(data => new DropZoneResp(data));
|
|
||||||
return details;
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SetFavoriteDropZone(selectedDz: DropZoneResp): boolean {
|
public SetFavoriteDropZone(selectedDz: DropZoneResp): boolean {
|
||||||
selectedDz.isFavorite = true;
|
selectedDz.isFavorite = true;
|
||||||
this.http
|
this.http.put(`${this.apiUrl}/DropZone/AddToFavorite/${selectedDz.id}`,
|
||||||
.put(`${this.apiUrl}/DropZone/${selectedDz.id}`, selectedDz, {
|
selectedDz,
|
||||||
headers: this.headers
|
{ headers: this.headers })
|
||||||
})
|
.subscribe(data => console.log(data));
|
||||||
.subscribe(data => console.log(data));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RemoveFavoriteDropZone(selectedDz: DropZoneResp): boolean {
|
public RemoveFavoriteDropZone(selectedDz: DropZoneResp): boolean {
|
||||||
selectedDz.isFavorite = false;
|
selectedDz.isFavorite = false;
|
||||||
this.http
|
this.http.put(`${this.apiUrl}/DropZone/RemoveToFavorite${selectedDz.id}`,
|
||||||
.put(`${this.apiUrl}/DropZone/${selectedDz.id}`, selectedDz, {
|
selectedDz,
|
||||||
headers: this.headers
|
{ headers: this.headers })
|
||||||
})
|
.subscribe(data => console.log(data));
|
||||||
.subscribe(data => console.log(data));
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddDropZone(
|
public AddDropZone(latitude: string,
|
||||||
latitude: string,
|
longitude: string,
|
||||||
longitude: string,
|
name: string,
|
||||||
name: string,
|
address: string,
|
||||||
address: string,
|
website: string,
|
||||||
website: string,
|
email: string,
|
||||||
email: string,
|
type: Array<string>,
|
||||||
type: Array<string>,
|
isFavorite: boolean) {
|
||||||
isFavorite: boolean
|
|
||||||
) {
|
|
||||||
const bodyNewDropZone: DropZoneReq = {
|
const bodyNewDropZone: DropZoneReq = {
|
||||||
id: 0,
|
id: 0,
|
||||||
latitude: latitude,
|
latitude: latitude,
|
||||||
@@ -70,10 +62,9 @@ export class DropzoneService extends BaseService {
|
|||||||
isFavorite: isFavorite
|
isFavorite: isFavorite
|
||||||
};
|
};
|
||||||
|
|
||||||
this.http
|
this.http.post(`${this.apiUrl}/DropZone`,
|
||||||
.post(`${this.apiUrl}/DropZone`, bodyNewDropZone, {
|
bodyNewDropZone,
|
||||||
headers: this.headers
|
{ headers: this.headers })
|
||||||
})
|
.subscribe(data => console.log(data));
|
||||||
.subscribe(data => console.log(data));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user