public ActionResult CreateShow(ShowEntity show) { bool isAdded = false; List <SelectListItem> screenList = ScreenBL.ViewAllScreenBL().Select(n => new SelectListItem { Value = n.ScreenId.ToString(), Text = n.ScreenName }).ToList();; var genreTip = new SelectListItem() { Value = null, Text = "--- select screen ---" }; screenList.Insert(0, genreTip); ViewBag.screenList = new SelectList(screenList, "Value", "Text"); if (ModelState.IsValid) { isAdded = ShowsBL.AddShowBL(show); if (isAdded) { return(RedirectToAction("IndexShowAdmin")); } } return(View(show)); }
public List <ShowEntityNew> ViewAllShowsAdminDAL() { List <ShowEntityNew> result = new List <ShowEntityNew>(); CinestarEntitiesDAL ObjContext = new CinestarEntitiesDAL(); var Objshow = new ShowEntity(); var ObjMovieList = from Shows in ObjContext.Shows join Movie in ObjContext.Movies on Shows.MovieId equals Movie.MovieId join Screen in ObjContext.Screens on Shows.ScreenId equals Screen.ScreenId select new ShowEntityNew { Movie = Movie.MovieName, Screen = Screen.ScreenName, Price = Shows.Price, ShowDate = Shows.ShowDate, ShowId = Shows.ShowId, ShowTime = Shows.ShowTime }; foreach (var item in ObjMovieList) { ShowEntityNew temp = new ShowEntityNew(); temp.Movie = item.Movie; temp.Price = item.Price; temp.Screen = item.Screen; temp.ShowDate = item.ShowDate; temp.ShowId = item.ShowId; temp.ShowTime = item.ShowTime; result.Add(temp); } return(result); }
private async Task <List <ShowEntity> > SaveShowsAsync(List <Show> shows) { var dbShowList = new List <ShowEntity>(); foreach (var show in shows) { var dbShow = await _dbContext.Shows.FirstOrDefaultAsync(s => s.ShowId == show.Id); if (dbShow != null) { UpdateShow(dbShow, show); } else { dbShow = new ShowEntity(); dbShow.ShowId = show.Id; dbShow.Name = show.Name; dbShow.CreatedAt = DateTime.UtcNow; await _dbContext.AddAsync(dbShow); } dbShowList.Add(dbShow); } await _dbContext.SaveChangesAsync(); return(dbShowList); }
// GET: Tickets/Details/5 public ActionResult CreateTicket() { int nooftickets = int.Parse(Request.QueryString["noofseats"]); int viewerId = int.Parse(Request.QueryString["viewerid"]); int showId = int.Parse(Request.QueryString["showid"]); int movieId = int.Parse(Request.QueryString["movieId"]); string seatnos = Request.QueryString["seatnumbers"]; ViewerProfileEntity viewer = ViewrProfilesBL.SearchViewerProfileByIdBL(viewerId); ShowEntity show = ShowsBL.SearchShowByIdBL(showId); MovyEntity movie = MovieBL.SearchMovieByIdBL(movieId); ScreenEntity screen = ScreenBL.SearchScreenByIdBL(show.ScreenId); ViewBag.ShowDate = show.ShowDate.ToShortDateString(); ViewBag.ShowId = show.ShowId; ViewBag.ViewerId = viewer.ViewersId; ViewBag.MovieName = movie.MovieName; ViewBag.Price = show.Price * nooftickets; ViewBag.NameOfCustomer = viewer.FirstName + " " + viewer.LastName; ViewBag.ScreenName = screen.ScreenName; ViewBag.noOfTickets = nooftickets; ViewBag.seatNos = seatnos; return(View()); }
public bool AddShowDAL(ShowEntity newShow) { bool showAdded = false; try { CinestarEntitiesDAL ObjContext = new CinestarEntitiesDAL(); var Objshow = new Show(); Objshow.ShowDate = newShow.ShowDate; Objshow.ShowTime = newShow.ShowTime; Objshow.MovieId = newShow.MovieId; Objshow.Price = newShow.Price; Objshow.ScreenId = newShow.ScreenId; ObjContext.Shows.Add(Objshow); int NoOfRowsAffected = ObjContext.SaveChanges(); bool showLayoutAdded = ShowSeatLayoutDAL.AddScreenLayout(Objshow.ShowId); if (NoOfRowsAffected > 0 && showLayoutAdded) { showAdded = true; } } catch (Exception ex) { throw new MovieExceptions("Error : Reading data", ex); } return(showAdded); }
public ActionResult ViewTicket(int id) { TicketEntity createTicket = new TicketEntity(); createTicket = TicketsBL.SearchTicketByIdBL(id); ViewerProfileEntity viewer = ViewrProfilesBL.SearchViewerProfileByIdBL(createTicket.ViewersId); ShowEntity show = ShowsBL.SearchShowByIdBL(createTicket.ShowId); MovyEntity movie = MovieBL.SearchMovieByIdBL(createTicket.MovieId); ScreenEntity screen = ScreenBL.SearchScreenByIdBL(show.ScreenId); ViewBag.ShowDate = show.ShowDate.ToShortDateString(); ViewBag.ShowId = show.ShowId; ViewBag.ViewerId = viewer.ViewersId; ViewBag.MovieName = movie.MovieName; ViewBag.Price = show.Price * createTicket.NoOfTickets; ViewBag.NameOfCustomer = viewer.FirstName + " " + viewer.LastName; ViewBag.ScreenName = screen.ScreenName; ViewBag.noOfTickets = createTicket.NoOfTickets; ViewBag.seatNos = createTicket.Seats; if (createTicket != null) { return(View()); } else { return(Redirect(string.Format("/Movies/ListAllMovies"))); } }
public bool UpdateShowDAL(ShowEntity updateShow) { bool showUpdated = false; try { CinestarEntitiesDAL ObjContext = new CinestarEntitiesDAL(); var objShow = new Show(); objShow = ObjContext.Shows.Find(updateShow.ShowId); if (objShow != null) { objShow.ShowDate = updateShow.ShowDate; objShow.ShowTime = updateShow.ShowTime; objShow.MovieId = updateShow.MovieId; objShow.Price = updateShow.Price; objShow.ScreenId = updateShow.ScreenId; int NoOfRowsAffected = ObjContext.SaveChanges(); showUpdated = NoOfRowsAffected > 0; } else { showUpdated = false; } } catch (Exception ex) { throw new MovieExceptions("Error : Reading data", ex); } return(showUpdated); }
private static bool ValidateShow(ShowEntity show) { StringBuilder sb = new StringBuilder(); bool validShow = true; List <MovyEntityNew> movie = MovieBL.GetAllMoviesBL(); var query = from movy in movie where movy.MovieId == show.MovieId select movy.ReleaseDate; DateTime date = Convert.ToDateTime(query.FirstOrDefault()); if (show.ShowDate < DateTime.Now || show.ShowDate < date) { validShow = false; sb.Append(Environment.NewLine + "Add valid Date"); } if (show.Price < 0) { validShow = false; sb.Append(Environment.NewLine + "Price should be positive"); } if (validShow == false) { throw new MovieExceptions(sb.ToString()); } return(validShow); }
public static ShowEntity SearchShowByIdDAL(int id) { ShowEntity searchShow = new ShowEntity(); try { CinestarEntitiesDAL ObjContext = new CinestarEntitiesDAL(); var ObjShow = ObjContext.Shows.Find(id); if (ObjShow != null) { searchShow.ScreenId = ObjShow.ScreenId; searchShow.MovieId = ObjShow.MovieId; searchShow.Price = ObjShow.Price; searchShow.ShowDate = ObjShow.ShowDate; searchShow.ShowId = ObjShow.ShowId; searchShow.ShowTime = ObjShow.ShowTime; } } catch (Exception ex) { throw new MovieExceptions("Error : Reading searching data", ex); } return(searchShow); }
public ShowDto(ShowEntity showEntity) { Id = showEntity.CorrelationId; Name = showEntity.Name; cast = showEntity.Actors .OrderByDescending(actor => actor.Birthday) .Select(actor => new ActorDto(actor)).ToList(); }
public async Task <IActionResult> AddShow([FromBody] ShowEntity showEntity) { if (showEntity == null) { return(BadRequest(Resources.ErrorMsg_ShowModelNull)); } if (showEntity.ProductionHouse == null || showEntity.ProductionHouse.ProductionHouseId == null || showEntity.ProductionHouse.ProductionHouseId.Equals(Guid.Empty)) { return(BadRequest(Resources.ErrorMsg_InvalidProductionId)); } if (showEntity.Language == null || showEntity.Language.LanguageId == null || showEntity.Language.LanguageId.Equals(Guid.Empty)) { return(BadRequest(Resources.ErrorMsg_InvalidLanguageId)); } if (showEntity.WatchStatus == null || showEntity.WatchStatus.WatchStatusId == 0) { return(BadRequest(Resources.ErrorMsg_InvalidStatusId)); } if (showEntity.OnlineChannel == null || showEntity.OnlineChannel.OnlineChannelId == null || showEntity.OnlineChannel.OnlineChannelId.Equals(Guid.Empty)) { return(BadRequest(Resources.ErrorMsg_InvalidChannelId)); } if (showEntity.Genre == null || !showEntity.Genre.Any()) { return(BadRequest(Resources.ErrorMsg_NoGenresFound)); } Show show = new Show() { ShowName = showEntity.ShowName, StatusId = showEntity.WatchStatus.WatchStatusId, ProductionHouseId = showEntity.ProductionHouse.ProductionHouseId, OnlineChannelId = showEntity.OnlineChannel.OnlineChannelId, LanguageId = showEntity.Language.LanguageId, Genre = string.Join(",", showEntity.Genre.OrderBy(g => g.GenreId).Select(t => t.GenreId).ToList()), AddedOn = HelperClass.ConvertEpochToDateTime(showEntity.AddedOn), Ended = showEntity.Ended, EpisodeLength = showEntity.EpisodeLength, Favorite = showEntity.Favorite, ModifiedOn = HelperClass.ConvertEpochToDateTime(showEntity.ModifiedOn.Value), NumberOfSeasons = showEntity.NumberOfSeasons, Rating = showEntity.Rating.Rating, Remarks = showEntity.Remarks, TotalEpisodes = showEntity.TotalEpisodes }; _context.Show.Add(show); await _context.SaveChangesAsync(); return(Ok(Resources.InfoMsg_ShowAddSuccess)); }
public void Constructor() { var entity = new EntityData(1, "NAME", "CARD_ID", Zone.DECK); var block = new MockBlockData(); var mod = new ShowEntity(entity, block); Assert.AreEqual(entity.Id, mod.EntityId); Assert.AreEqual(entity.CardId, mod.CardId); Assert.AreEqual(block, mod.ParentBlock); }
public ActionResult DetailsShow(int id) { ShowEntity show = ShowsBL.SearchShowByIdBL(id); if (show == null) { return(HttpNotFound()); } return(View(show)); }
public void GameStateChange_ShowEntity() { ShowEntity showEntity = null; var parser = new PowerParser(new MockGameInfo()); parser.GameStateChange += args => showEntity = args as ShowEntity; parser.Parse(new Line("Power", "D 00:30:21.0673837 PowerTaskList.DebugPrintPower() - SHOW_ENTITY - Updating Entity=[entityName=UNKNOWN ENTITY [cardType=INVALID] id=72 zone=DECK zonePos=0 cardId= player=2] CardID=UNG_015")); Assert.IsNotNull(showEntity); Assert.AreEqual(72, showEntity.EntityId); Assert.AreEqual("UNG_015", showEntity.CardId); }
public void Apply_ValidEntity_RevealCard() { var entity = new EntityData(1, "NAME", "CARD_ID", Zone.DECK); var game = new MockGameState(); game.Entities.Add(1, new Entity(1, "")); var mod = new ShowEntity(entity, new MockBlockData { Type = BlockType.REVEAL_CARD }); mod.Apply(game); Assert.IsTrue(game.Entities[entity.Id].Info.JoustReveal); }
// GET: Shows/Delete/5 public ActionResult DeleteShow(int id) { //if (id == null) //{ // return new HttpStatusCodeResult(HttpStatusCode.BadRequest); //} ShowEntity show = ShowsBL.SearchShowByIdBL(id); if (show == null) { return(HttpNotFound()); } return(View(show)); }
public ActionResult EditShow(ShowEntity show) { bool isUpdated = false; if (ModelState.IsValid) { isUpdated = ShowsBL.UpdateShowBL(show); if (isUpdated) { return(RedirectToAction("Index/1")); } } return(View(show)); }
public void Apply_ValidEntity() { var entityData = new EntityData(1, "NAME", "CARD_ID", Zone.DECK); var game = new MockGameState(); var entity = new Entity(1, ""); entity.Info.Hidden = true; game.Entities.Add(1, entity); var mod = new ShowEntity(entityData, new MockBlockData()); mod.Apply(game); Assert.IsFalse(game.Entities[entityData.Id].Info.Hidden); Assert.IsFalse(game.Entities[entityData.Id].Info.JoustReveal); Assert.AreEqual(entityData.CardId, game.Entities[entityData.Id].CardId); }
public void Apply_InvalidEntity() { var entityData = new EntityData(2, "NAME", "CARD_ID", Zone.DECK); var game = new MockGameState(); var entity = new Entity(1, ""); entity.Info.Hidden = true; game.Entities.Add(1, entity); var mod = new ShowEntity(entityData, new MockBlockData()); mod.Apply(game); Assert.AreNotEqual(entityData.CardId, game.Entities[1].CardId); Assert.IsTrue(game.Entities[1].Info.Hidden); Assert.AreEqual(1, game.Entities.Count); }
public static ShowEntity SearchShowByIdBL(int showId) { ShowEntity searchShow = null; try { searchShow = ShowsDAL.SearchShowByIdDAL(showId); } catch (MovieExceptions ex) { throw ex; } catch (Exception ex) { throw ex; } return(searchShow); }
// GET: Shows/Create public ActionResult CreateShow(int id) { ShowEntity show = new ShowEntity(); show.MovieId = id; List <SelectListItem> screenList = ScreenBL.ViewAllScreenBL().Select(n => new SelectListItem { Value = n.ScreenId.ToString(), Text = n.ScreenName }).ToList();; var genreTip = new SelectListItem() { Value = null, Text = "--- select screen ---" }; screenList.Insert(0, genreTip); ViewBag.screenList = new SelectList(screenList, "Value", "Text"); return(View(show)); }
static void insertToDB(List <Show> shows) { var optionsBuilder = new DbContextOptionsBuilder <RtlDbContext>(); optionsBuilder.UseSqlServer(Resources.DefaultConnection); var dbContext = new RtlDbContext(optionsBuilder.Options); dbContext.Database.EnsureCreated(); var dbShows = new List <ShowEntity>(); foreach (var show in shows) { var showEntity = new ShowEntity(); showEntity.Name = show.Name; showEntity.CorrelationId = show.Id; showEntity.Actors = new List <ActorEntity>(); List <Actor> actors = readPersonFile(show.Id); foreach (var actor in actors) { ActorEntity actorEntity = new ActorEntity(); actorEntity.Name = actor.Person.Name; actorEntity.CorrelationId = actor.Person.Id; if (actor.Person.Birthday.HasValue) { actorEntity.Birthday = actor.Person.Birthday.Value.Date; } showEntity.Actors.Add(actorEntity); } dbShows.Add(showEntity); } dbContext.Shows.AddRange(dbShows); dbContext.SaveChanges(); }
public ActionResult CreateTicket(TicketEntity ticket) { int nooftickets = int.Parse(Request.QueryString["noofseats"]); int viewerId = int.Parse(Request.QueryString["viewerid"]); int showId = int.Parse(Request.QueryString["showid"]); int movieId = int.Parse(Request.QueryString["movieId"]); string seatnos = Request.QueryString["seatnumbers"]; ViewerProfileEntity viewer = ViewrProfilesBL.SearchViewerProfileByIdBL(viewerId); ShowEntity show = ShowsBL.SearchShowByIdBL(showId); MovyEntity movie = MovieBL.SearchMovieByIdBL(movieId); ScreenEntity screen = ScreenBL.SearchScreenByIdBL(show.ScreenId); TicketEntity createTicket = new TicketEntity(); createTicket.NoOfTickets = nooftickets; createTicket.ShowId = showId; ViewBag.MovieName = movie.MovieName; createTicket.Price = show.Price * nooftickets; createTicket.ViewersId = viewer.ViewersId; createTicket.TransactionDate = DateTime.Now.Date; createTicket.MovieId = movie.MovieId; createTicket.Seats = seatnos; if (ModelState.IsValid) { var IsAdded = TicketsBL.CreateTicketBL(createTicket); if (IsAdded) { return(Redirect(string.Format("/Payments/CompletePayment"))); } else { return(Redirect(string.Format("/SeatLayout/SelectSeatsView"))); } } else { return(Redirect(string.Format("/SeatLayout/SelectSeatsView"))); } }
public static bool AddShowBL(ShowEntity newShow) { bool showAdded = false; try { if (ValidateShow(newShow)) { ShowsDAL showDAL = new ShowsDAL(); showAdded = showDAL.AddShowDAL(newShow); } } catch (MovieExceptions) { throw; } catch (Exception ex) { throw ex; } return(showAdded); }
public List <ShowEntity> ViewAllShowsDAL(int id) { List <ShowEntity> objShowList = new List <ShowEntity>(); CinestarEntitiesDAL ObjContext = new CinestarEntitiesDAL(); var Objshow = new ShowEntity(); var query = from show in ObjContext.Shows where show.MovieId == id select show; ShowEntity ObjTempShow = null; foreach (var d in query) { ObjTempShow = new ShowEntity(); ObjTempShow.MovieId = d.MovieId; ObjTempShow.Price = d.Price; ObjTempShow.ShowId = d.ShowId; ObjTempShow.ScreenId = d.ScreenId; ObjTempShow.ShowDate = d.ShowDate; ObjTempShow.ShowTime = d.ShowTime; objShowList.Add(ObjTempShow); } return(objShowList); }
public async Task <IActionResult> UpdateShow(Guid showId, [FromBody] ShowEntity showEntity) { if (showId == null || showId.Equals(Guid.Empty)) { return(BadRequest(Resources.ErrorMsg_InvalidShowId)); } var show = await _context.Show.FirstOrDefaultAsync(s => s.ShowId == showId); if (show == null) { return(BadRequest(Resources.ErrorMsg_ShowNotFound)); } show.ShowName = showEntity.ShowName; show.StatusId = showEntity.WatchStatus.WatchStatusId; show.ProductionHouseId = showEntity.ProductionHouse.ProductionHouseId; //show.OnlineChannelId = showEntity.OnlineChannel.OnlineChannelId; //show.LanguageId = showEntity.Language.LanguageId; show.Genre = string.Join(",", showEntity.Genre.OrderBy(g => g.GenreId).Select(t => t.GenreId).ToList()); //show.AddedOn = HelperClass.ConvertEpochToDateTime(showEntity.AddedOn); show.Ended = showEntity.Ended; //show.EpisodeLength = showEntity.EpisodeLength; show.Favorite = showEntity.Favorite; show.ModifiedOn = HelperClass.ConvertEpochToDateTime(showEntity.ModifiedOn.Value); show.NumberOfSeasons = showEntity.NumberOfSeasons; show.Rating = showEntity.Rating.Rating; show.Remarks = showEntity.Remarks; show.TotalEpisodes = showEntity.TotalEpisodes; _context.Show.Update(show); await _context.SaveChangesAsync(); return(Ok(Resources.InfoMsg_ShowUpdateSuccess)); }
public static bool UpdateShowBL(ShowEntity updateShow) { bool showUpdated = false; try { if (ValidateShow(updateShow)) { ShowsDAL showDAL = new ShowsDAL(); showUpdated = showDAL.UpdateShowDAL(updateShow); } } catch (MovieExceptions ex) { throw ex; } catch (Exception ex) { throw ex; } return(showUpdated); }
private void UpdateShow(ShowEntity dbShow, Show show) { dbShow.Name = show.Name; dbShow.ModifiedAt = DateTime.UtcNow; _dbContext.Update(dbShow); }
private ShowEntity ParseShowEntity(int from, int to) { var entity = new ShowEntity(); var showEntityLine = lines[from]; var regex = new Regex(@"CardID=(?<cardid>[\w\d_]+)"); var match = regex.Match(lines[from]); entity.Entity.CardId = match.Groups["cardid"].Value; var tagRegex = new Regex(@"tag=(?<name>\w+)\svalue=(?<value>[\w\d_]+)"); for (var i = from; i < to; i++) { var tagMatch = tagRegex.Match(lines[i]); if (tagMatch.Success) entity.Tags.Add(new Tag() { Name = tagMatch.Groups["name"].Value, Value = tagMatch.Groups["value"].Value }); } return entity; }
private ShowEntity ParseShowEntity2(Match match) { var entity = new ShowEntity(); //entity.Entity.Id = Int16.Parse(match.Groups["id"].Value); //entity.Entity.Zone = match.Groups["zone"].Value; //entity.Entity.ZonePos = Int16.Parse(match.Groups["zonepos"].Value); //entity.Entity.Player = Int16.Parse(match.Groups["player"].Value); entity.Entity.CardId = match.Groups["cardid"].Value; return entity; }
public static void Handle(string timestamp, string data, ParserState state) { var trimmed = data.Trim(); var indentLevel = data.Length - trimmed.Length; data = trimmed; if (state.Node != null && indentLevel <= state.Node.IndentLevel) { var action = state.Node.Object as Action; if (action == null || action.Entity != 1 || !data.ToLower().Contains("mulligan")) { state.Node = state.Node.Parent ?? state.Node; } } if (data == "CREATE_GAME") { state.CurrentGame = new Game { Data = new List <GameData>(), TimeStamp = timestamp }; state.Replay.Games.Add(state.CurrentGame); state.Node = new Node(typeof(Game), state.CurrentGame, 0, null); return; } var match = Regexes.ActionCreategameRegex.Match(data); if (match.Success) { var id = match.Groups[1].Value; Debug.Assert(id == "1"); var gEntity = new GameEntity { Id = int.Parse(id), Tags = new List <Tag>() }; state.CurrentGame.Data.Add(gEntity); state.Node = new Node(typeof(GameEntity), gEntity, indentLevel, state.Node); return; } match = Regexes.ActionCreategamePlayerRegex.Match(data); if (match.Success) { var id = match.Groups[1].Value; var playerId = match.Groups[2].Value; var accountHi = match.Groups[3].Value; var accountLo = match.Groups[4].Value; var pEntity = new PlayerEntity { Id = int.Parse(id), AccountHi = accountHi, AccountLo = accountLo, PlayerId = int.Parse(playerId), Tags = new List <Tag>() }; state.CurrentGame.Data.Add(pEntity); state.Node = new Node(typeof(PlayerEntity), pEntity, indentLevel, state.Node); return; } match = Regexes.ActionStartRegex.Match(data); if (match.Success) { var rawEntity = match.Groups[1].Value; var rawType = match.Groups[2].Value; var index = match.Groups[3].Value; var rawTarget = match.Groups[4].Value; var entity = Helper.ParseEntity(rawEntity, state); var target = Helper.ParseEntity(rawTarget, state); var type = Helper.ParseEnum <PowSubType>(rawType); var action = new Action { Data = new List <GameData>(), Entity = entity, Index = int.Parse(index), Target = target, TimeStamp = timestamp, Type = type }; if (state.Node.Type == typeof(Game)) { ((Game)state.Node.Object).Data.Add(action); } else if (state.Node.Type == typeof(Action)) { ((Action)state.Node.Object).Data.Add(action); } else { throw new Exception("Invalid node " + state.Node.Type); } state.Node = new Node(typeof(Action), action, indentLevel, state.Node); return; } match = Regexes.ActionMetadataRegex.Match(data); if (match.Success) { var rawMeta = match.Groups[1].Value; var rawData = match.Groups[2].Value; var info = match.Groups[3].Value; var parsedData = Helper.ParseEntity(rawData, state); var meta = Helper.ParseEnum <MetaDataType>(rawMeta); var metaData = new MetaData { Data = parsedData, Info = int.Parse(info), Meta = meta, MetaInfo = new List <Info>() }; if (state.Node.Type == typeof(Action)) { ((Action)state.Node.Object).Data.Add(metaData); } else { throw new Exception("Invalid node " + state.Node.Type); } state.Node = new Node(typeof(MetaData), metaData, indentLevel, state.Node); return; } match = Regexes.ActionMetaDataInfoRegex.Match(data); if (match.Success) { var index = match.Groups[1].Value; var rawEntity = match.Groups[2].Value; var entity = Helper.ParseEntity(rawEntity, state); var metaInfo = new Info { Id = entity, Index = int.Parse(index) }; if (state.Node.Type == typeof(MetaData)) { ((MetaData)state.Node.Object).MetaInfo.Add(metaInfo); } else { throw new Exception("Invalid node " + state.Node.Type); } } match = Regexes.ActionShowEntityRegex.Match(data); if (match.Success) { var rawEntity = match.Groups[1].Value; var cardId = match.Groups[2].Value; var entity = Helper.ParseEntity(rawEntity, state); var showEntity = new ShowEntity { CardId = cardId, Entity = entity, Tags = new List <Tag>() }; if (state.Node.Type == typeof(Game)) { ((Game)state.Node.Object).Data.Add(showEntity); } else if (state.Node.Type == typeof(Action)) { ((Action)state.Node.Object).Data.Add(showEntity); } else { throw new Exception("Invalid node " + state.Node.Type); } state.Node = new Node(typeof(ShowEntity), showEntity, indentLevel, state.Node); return; } match = Regexes.ActionHideEntityRegex.Match(data); if (match.Success) { var rawEntity = match.Groups[1].Value; var tagName = match.Groups[2].Value; var value = match.Groups[3].Value; var entity = Helper.ParseEntity(rawEntity, state); var zone = Helper.ParseTag(tagName, value); var hideEntity = new HideEntity { Entity = entity, Zone = zone.Value, TimeStamp = timestamp }; if (state.Node.Type == typeof(Game)) { ((Game)state.Node.Object).Data.Add(hideEntity); } else if (state.Node.Type == typeof(Action)) { ((Action)state.Node.Object).Data.Add(hideEntity); } else { throw new Exception("Invalid node: " + state.Node.Type); } return; } match = Regexes.ActionFullEntityUpdatingRegex.Match(data); if (!match.Success) { match = Regexes.ActionFullEntityCreatingRegex.Match(data); } if (match.Success) { var rawEntity = match.Groups[1].Value; var cardId = match.Groups[2].Value; var entity = Helper.ParseEntity(rawEntity, state); var showEntity = new FullEntity { CardId = cardId, Id = entity, Tags = new List <Tag>() }; if (state.Node.Type == typeof(Game)) { ((Game)state.Node.Object).Data.Add(showEntity); } else if (state.Node.Type == typeof(Action)) { ((Action)state.Node.Object).Data.Add(showEntity); } else { throw new Exception("Invalid node " + state.Node.Type); } state.Node = new Node(typeof(FullEntity), showEntity, indentLevel, state.Node); return; } match = Regexes.ActionTagChangeRegex.Match(data); if (match.Success) { var rawEntity = match.Groups[1].Value; var tagName = match.Groups[2].Value; var value = match.Groups[3].Value; var tag = Helper.ParseTag(tagName, value); if (tag.Name == (int)GameTag.CURRENT_PLAYER) { UpdateCurrentPlayer(state, rawEntity, tag); } var entity = Helper.ParseEntity(rawEntity, state); if (tag.Name == (int)GameTag.ENTITY_ID) { entity = UpdatePlayerEntity(state, rawEntity, tag, entity); } var tagChange = new TagChange { Entity = entity, Name = tag.Name, Value = tag.Value }; if (state.Node.Type == typeof(Game)) { ((Game)state.Node.Object).Data.Add(tagChange); } else if (state.Node.Type == typeof(Action)) { ((Action)state.Node.Object).Data.Add(tagChange); } else { throw new Exception("Invalid node " + state.Node.Type); } return; } match = Regexes.ActionTagRegex.Match(data); if (match.Success) { var tagName = match.Groups[1].Value; var value = match.Groups[2].Value; var tag = Helper.ParseTag(tagName, value); if (tag.Name == (int)GameTag.CURRENT_PLAYER) { state.FirstPlayerId = ((PlayerEntity)state.Node.Object).Id; } if (state.Node.Type == typeof(GameEntity)) { ((GameEntity)state.Node.Object).Tags.Add(tag); } else if (state.Node.Type == typeof(PlayerEntity)) { ((PlayerEntity)state.Node.Object).Tags.Add(tag); } else if (state.Node.Type == typeof(FullEntity)) { ((FullEntity)state.Node.Object).Tags.Add(tag); } else if (state.Node.Type == typeof(ShowEntity)) { ((ShowEntity)state.Node.Object).Tags.Add(tag); } else { throw new Exception("Invalid node " + state.Node.Type + " -- " + data); } } }
public async Task AddNewShowAsync(ShowEntity show) { await _context.GetShowsCollection().InsertOneAsync(show); }