Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions Beam.Client/Services/BeamApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ internal async Task<List<Ray>> AddRay(Ray ray)

internal async Task<User> GetOrCreateUser(string name)
{
return (await http.GetFromJsonAsync<User>($"api/User/Get/{name}")) ?? new User();
var resp = await http.PostAsync($"api/User/Get/{name}", null);
resp.EnsureSuccessStatusCode();
return (await resp.Content.ReadFromJsonAsync<User>()) ?? new User();
}

internal async Task<List<Ray>> PrismRay(Prism prism)
Expand All @@ -51,7 +53,9 @@ internal async Task<List<Ray>> PrismRay(Prism prism)

internal async Task<List<Ray>> UnPrismRay(int rayId, int userId)
{
return (await http.GetFromJsonAsync<List<Ray>>($"api/Prism/Remove/{userId}/{rayId}")) ?? new List<Ray>();
var resp = await http.DeleteAsync($"api/Prism/Remove/{userId}/{rayId}");
resp.EnsureSuccessStatusCode();
return (await resp.Content.ReadFromJsonAsync<List<Ray>>()) ?? new List<Ray>();
}

internal async Task<List<Ray>> UserRays(string name)
Expand Down
4 changes: 2 additions & 2 deletions Beam.Server/Controllers/PrismController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public List<Ray> Add([FromBody] Prism prism)
.ToList();
}

[HttpGet("[action]/{UserId}/{RayId}")]
[HttpDelete("[action]/{UserId}/{RayId}")]
public List<Ray> Remove(int UserId, int RayId)
{
var removePrisms = _context.Prisms.Include(p => p.Ray).Where(p => p.RayId == RayId && p.UserId == UserId).ToList();
Expand All @@ -53,4 +53,4 @@ public List<Ray> Remove(int UserId, int RayId)
}

}
}
}
4 changes: 2 additions & 2 deletions Beam.Server/Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public UserController(Data.BeamContext context)
_context = context;
}

[HttpGet("[action]/{Username}")]
[HttpPost("[action]/{Username}")]
public User Get(string Username)
{
var existingUser = _context.Users.FirstOrDefault(u => u.Username == Username);
Expand All @@ -31,4 +31,4 @@ public User Get(string Username)
}

}
}
}