public IActionResult Edit(SessionModel model) { Hall hall = _hallService.GetById(model.HallId); if (hall == null) { return(Fail("找不到影厅信息")); } SeatListResponse.Seat seat = JsonConvert.DeserializeObject <SeatListResponse.Seat>(hall.SeatJson); if (!model.SessionId.HasValue || model.SessionId <= 0) { ApiResult <bool> apiResult = _sessionService.Create(new CreateSessionReqs() { ActivityId = model.ActivityId, CinemaId = model.CinemaId, HallId = model.HallId, Seats = model.SeatNos.SelectMany(seatNo => seat.sections[0].seats.SelectMany(o => o.columns.Select(x => new { x.seatNo, o.rowId, x.columnId })) .Where(x => x.seatNo == seatNo) .Select(o => new SeatInfoReqs { SeatNo = seatNo, ColumnId = o.columnId, RowId = o.rowId })).ToArray() }); return(Json(apiResult)); } else { ApiResult <bool> apiResult = _sessionService.Change(new UpdateSessionReqs() { ActivityId = model.ActivityId, SessionId = model.SessionId.Value, CinemaId = model.CinemaId, HallId = model.HallId, Seats = model.SeatNos.SelectMany(seatNo => seat.sections[0].seats.SelectMany(o => o.columns.Select(x => new { x.seatNo, o.rowId, x.columnId })) .Where(x => x.seatNo == seatNo) .Select(o => new SeatInfoReqs { SeatNo = seatNo, ColumnId = o.columnId, RowId = o.rowId })).ToArray() }); return(Json(apiResult)); } }