private Encounter AddNew(Encounter aMatch) { EncounterEntity toAdd = matchConverter.ToEntity(aMatch); context.Entry(toAdd).State = EntityState.Added; AddComments(toAdd, aMatch.GetAllCommentaries()); //We also need to ask if it is an Sql database, so that we can execute the sql scripts. if (aMatch.Id > 0 && context.Database.IsSqlServer()) { SaveWithIdentityInsert(); } else { context.SaveChanges(); } Encounter added = factory.CreateEncounter(toAdd.Id, aMatch.GetParticipants(), aMatch.Date, aMatch.Sport); ICollection <EncounterTeam> playingTeams = matchConverter.ConvertParticipants(added); foreach (EncounterTeam team in playingTeams) { context.Entry(team).State = EntityState.Added; } context.SaveChanges(); context.Entry(toAdd).State = EntityState.Detached; return(added); }
public void MatchToEntityDateTest() { EncounterEntity converted = testMapper.ToEntity(match); Assert.AreEqual(converted.Date.ToString(), entity.Date.ToString()); }