public static void Load(this BbqEvent bbqEvent, BbqEventViewModel viewModel) { bbqEvent.Id = viewModel.Id; bbqEvent.EventName = viewModel.EventName; bbqEvent.EventDate = viewModel.EventDate.LocalDateTime; bbqEvent.TurnInTime = viewModel.TurnInTime.LocalDateTime; }
public async Task LogItems([FromBody] ItemLoggingRequest request) { BbqEvent bbqEvent = this.context.Events.Find(request.Event.Id); if (bbqEvent == null) { this.context.Events.Add(request.Event); } BbqItem bbqItem = this.context.Items.Find(request.Item.Id); if (bbqItem == null) { this.context.Items.Add(request.Item); } foreach (BbqItemLog log in request.ItemLogs) { var existing = this.context.ItemLogs.Find(log.Id); if (existing == null) { this.context.ItemLogs.Add(log); } } await this.context.SaveChangesAsync(); }
public async Task <BbqEvent> UpdateEventAsync(BbqEvent bbqEvent) { using (await this.dbLock.LockAsync()) { this.context.Events.Update(bbqEvent); await this.context.SaveChangesAsync(); return(bbqEvent); } }
public async Task LogSmoker([FromBody] SmokerLoggingRequest request) { BbqEvent bbqEvent = this.context.Events.Find(request.Event.Id); if (bbqEvent == null) { this.context.Events.Add(request.Event); } foreach (SmokerLog log in request.SmokerLogs) { var existing = this.context.SmokerLog.Find(log.Id); if (existing == null) { this.context.SmokerLog.Add(log); } } await this.context.SaveChangesAsync(); }