make app project standalone

This commit is contained in:
2023-08-04 09:05:13 +08:00
parent 31cfaee4f0
commit cec1e3bf71
82 changed files with 56 additions and 5124 deletions

View File

@@ -299,6 +299,14 @@ public class FlowerApiController : BaseController
return NotFound($"Flower id {id} not found");
}
var loc = database.Records
.OrderByDescending(r => r.DateUnixTime)
.FirstOrDefault(r => r.FlowerId == id && (r.EventId == (int)EventTypes.Move || r.EventId == (int)EventTypes.Born));
if (loc != null)
{
item.Location = loc.Memo;
}
if (includePhoto == true)
{
item.Photos = database.Photos.Where(p => p.FlowerId == item.Id && p.RecordId == null).ToList();
@@ -459,6 +467,20 @@ public class FlowerApiController : BaseController
return NotFound();
}
FileResult? file;
if (flower.Cover?.Length > 0)
{
file = WrapFormFile(flower.Cover);
if (file == null)
{
return BadRequest();
}
}
else
{
file = null;
}
var item = new FlowerItem
{
OwnerId = user.Id,
@@ -475,14 +497,24 @@ public class FlowerApiController : BaseController
SaveDatabase();
var now = user.ActiveDateUnixTime ?? DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
if (flower.Cover?.Length > 0)
if (flower.Location != null)
{
var file = WrapFormFile(flower.Cover);
if (file == null)
var record = new RecordItem
{
return BadRequest();
}
FlowerId = item.Id,
EventId = (int)EventTypes.Born,
DateUnixTime = now,
OwnerId = user.Id,
Latitude = flower.Latitude,
Longitude = flower.Longitude,
Memo = flower.Location
};
database.Records.Add(record);
SaveDatabase();
}
if (file != null)
{
try
{
await ExecuteTransaction(async token =>