mirror of
https://github.com/BarkProductions/barkman.git
synced 2026-08-11 11:42:03 +00:00
added endpoints and fixed some typos
This commit is contained in:
+62
-10
@@ -55,6 +55,10 @@ var jobGroup = app.MapGroup(prefix: "/jobs")
|
|||||||
.WithTags("Jobs")
|
.WithTags("Jobs")
|
||||||
.WithDescription("Endpoints for managing jobs");
|
.WithDescription("Endpoints for managing jobs");
|
||||||
|
|
||||||
|
var jobStatusGroup = app.MapGroup(prefix: "/jobstatus")
|
||||||
|
.WithTags("Job Status")
|
||||||
|
.WithDescription("Endpoints for managing job status");
|
||||||
|
|
||||||
var jobItemGroup = app.MapGroup(prefix: "/jobitems")
|
var jobItemGroup = app.MapGroup(prefix: "/jobitems")
|
||||||
.WithTags("Job Items")
|
.WithTags("Job Items")
|
||||||
.WithDescription("Endpoints for managing job items");
|
.WithDescription("Endpoints for managing job items");
|
||||||
@@ -152,7 +156,7 @@ itemStatusGroup.MapPut("/{id}", async (string id, ItemStatus updatedStatus, Bark
|
|||||||
var existingStatus = await db.ItemStatus.FindAsync(id);
|
var existingStatus = await db.ItemStatus.FindAsync(id);
|
||||||
if (existingStatus == null)
|
if (existingStatus == null)
|
||||||
{
|
{
|
||||||
return Results.NotFound(new { Message = "Inventory item not found" });
|
return Results.NotFound(new { Message = "Item status not found" });
|
||||||
}
|
}
|
||||||
|
|
||||||
existingStatus.Id = updatedStatus.Id;
|
existingStatus.Id = updatedStatus.Id;
|
||||||
@@ -256,21 +260,21 @@ jobGroup.MapGet("/{id}", async (int id, BarkContext db) =>
|
|||||||
return Results.Ok(job);
|
return Results.Ok(job);
|
||||||
});
|
});
|
||||||
|
|
||||||
jobGroup.MapPut("/{id}", async (int id, Jobs ubdatedJob, BarkContext db) =>
|
jobGroup.MapPut("/{id}", async (int id, Jobs updatedJob, BarkContext db) =>
|
||||||
{
|
{
|
||||||
var existingJob = await db.Jobs.FindAsync(id);
|
var existingJob = await db.Jobs.FindAsync(id);
|
||||||
if (existingJob == null)
|
if (existingJob == null)
|
||||||
{
|
{
|
||||||
return Results.NotFound(new { Message = "Customer not found" });
|
return Results.NotFound(new { Message = "Job not found" });
|
||||||
}
|
}
|
||||||
|
|
||||||
existingJob.Name = ubdatedJob.Name;
|
existingJob.Name = updatedJob.Name;
|
||||||
existingJob.StartDate = ubdatedJob.StartDate;
|
existingJob.StartDate = updatedJob.StartDate;
|
||||||
existingJob.EndDate = ubdatedJob.EndDate;
|
existingJob.EndDate = updatedJob.EndDate;
|
||||||
existingJob.TotalPrice = ubdatedJob.TotalPrice;
|
existingJob.TotalPrice = updatedJob.TotalPrice;
|
||||||
existingJob.Venue = ubdatedJob.Venue;
|
existingJob.Venue = updatedJob.Venue;
|
||||||
existingJob.Address = ubdatedJob.Address;
|
existingJob.Address = updatedJob.Address;
|
||||||
existingJob.Notes = ubdatedJob.Notes;
|
existingJob.Notes = updatedJob.Notes;
|
||||||
|
|
||||||
await db.SaveChangesAsync();
|
await db.SaveChangesAsync();
|
||||||
return Results.Ok(existingJob);
|
return Results.Ok(existingJob);
|
||||||
@@ -293,6 +297,54 @@ jobGroup.MapPost("", async (Jobs newJobInput, BarkContext db) =>
|
|||||||
return Results.Created($"/jobs/{newJob.Id}", newJob);
|
return Results.Created($"/jobs/{newJob.Id}", newJob);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
jobStatusGroup.MapGet("/", async (BarkContext db) =>
|
||||||
|
await db.JobStatus.ToListAsync());
|
||||||
|
|
||||||
|
jobStatusGroup.MapPost("/", async (JobStatus newJobStatus, BarkContext db) =>
|
||||||
|
{
|
||||||
|
db.JobStatus.Add(newJobStatus);
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
return Results.Created($"/jobstatus/{newJobStatus.Id}", newJobStatus);
|
||||||
|
});
|
||||||
|
|
||||||
|
jobStatusGroup.MapGet("/{id}", async (string id, BarkContext db) =>
|
||||||
|
{
|
||||||
|
var jobStatus = await db.JobStatus.FindAsync(id);
|
||||||
|
if (jobStatus == null)
|
||||||
|
{
|
||||||
|
return Results.NotFound(new { Message = "Job Status not found" });
|
||||||
|
}
|
||||||
|
|
||||||
|
return Results.Ok(jobStatus);
|
||||||
|
});
|
||||||
|
|
||||||
|
jobStatusGroup.MapPut("/{id}", async (string id, JobStatus updatedStatus, BarkContext db) =>
|
||||||
|
{
|
||||||
|
var existingStatus = await db.JobStatus.FindAsync(id);
|
||||||
|
if (existingStatus == null)
|
||||||
|
{
|
||||||
|
return Results.NotFound(new { Message = "Job status not found" });
|
||||||
|
}
|
||||||
|
|
||||||
|
existingStatus.Id = updatedStatus.Id;
|
||||||
|
existingStatus.Name = updatedStatus.Name;
|
||||||
|
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
return Results.Ok(existingStatus);
|
||||||
|
});
|
||||||
|
|
||||||
|
jobStatusGroup.MapDelete("/{id}", async (string id, BarkContext db) =>
|
||||||
|
{
|
||||||
|
var jobStatus = await db.JobStatus.FindAsync(id);
|
||||||
|
if (jobStatus == null)
|
||||||
|
{
|
||||||
|
return Results.NotFound(new { Message = "Job status not found" });
|
||||||
|
}
|
||||||
|
|
||||||
|
db.JobStatus.Remove(jobStatus);
|
||||||
|
await db.SaveChangesAsync();
|
||||||
|
return Results.Ok(new { Message = "Job status deleted successfully" });
|
||||||
|
});
|
||||||
|
|
||||||
using (var serviceScope = app.Services.CreateScope())
|
using (var serviceScope = app.Services.CreateScope())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user