public void AddHistoryEntry(string name, PriceHistoryEntry entry) { var location = GetOrCreate(name, false); location.PriceHistory.Add(entry); context.SaveChanges(); }
public IActionResult AddPriceHistoryEntry(string name, [FromBody] PriceHistoryEntry newEntry) { // Check if a date is provided, otherwise use the current time. newEntry.Date = newEntry.Date == DateTime.MinValue ? TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, "Europe/Amsterdam") : newEntry.Date; try { locationService.AddHistoryEntry(name, newEntry); return(NoContent()); } catch (Exception e) { return(BadRequest(e)); } }