public static string ImportCards(StationsDbContext context, string xmlString) { var cards = new List <CustomerCard>(); var result = new StringBuilder(); var serializer = new XmlSerializer(typeof(CustomerCardDto[]), new XmlRootAttribute("Cards")); var objCards = (CustomerCardDto[])serializer.Deserialize(new MemoryStream(Encoding.UTF8.GetBytes(xmlString))); foreach (var objCard in objCards) { if (!IsValid(objCard)) { result.AppendLine(FailureMessage); continue; } var type = Enum.Parse <CardType>(objCard.CardType); var card = new CustomerCard { Name = objCard.Name, Age = objCard.Age, Type = type }; cards.Add(card); result.AppendLine(string.Format(SuccessMessage, card.Name)); } context.Cards.AddRange(cards); context.SaveChanges(); return(result.ToString()); }
public static string ImportCards(StationsDbContext context, string xmlString) { var sb = new StringBuilder(); var serializer = new XmlSerializer(typeof(CardDto[]), new XmlRootAttribute("Cards")); var deserializedCards = (CardDto[])serializer.Deserialize(new MemoryStream(Encoding.UTF8.GetBytes(xmlString))); var validCards = new List <CustomerCard>(); foreach (var cardDto in deserializedCards) { if (!IsValid(cardDto)) { sb.AppendLine(FailureMessage); continue; } var card = Mapper.Map <CustomerCard>(cardDto); if (cardDto.CardType != null) { var type = Enum.Parse <CardType>(cardDto.CardType); card.Type = type; } validCards.Add(card); sb.AppendLine(string.Format(SuccessMessage, cardDto.Name)); } context.Cards.AddRange(validCards); context.SaveChanges(); return(sb.ToString()); }
public static string ImportClasses(StationsDbContext context, string jsonString) { var sb = new StringBuilder(); var deserializedClasses = JsonConvert.DeserializeObject <SeatingClassDto[]>(jsonString); var validClasses = new List <SeatingClass>(); foreach (var classDto in deserializedClasses) { if (!IsValid(classDto) || validClasses.Any(sc => sc.Name == classDto.Name || sc.Abbreviation == classDto.Abbreviation)) { sb.AppendLine(FailureMessage); continue; } var seatingClass = Mapper.Map <SeatingClass>(classDto); validClasses.Add(seatingClass); sb.AppendLine(string.Format(SuccessMessage, classDto.Name)); } context.SeatingClasses.AddRange(validClasses); context.SaveChanges(); return(sb.ToString()); }
public static string ImportClasses(StationsDbContext context, string jsonString) { var sb = new StringBuilder(); var classesDto = JsonConvert.DeserializeObject <ClassesDto[]>(jsonString); var classes = new List <SeatingClass>(); foreach (var dto in classesDto) { if (dto.Abbreviation == null || dto.Name == null || dto.Name.Length > 30 || dto.Abbreviation.Length != 2) { sb.AppendLine(FailureMessage); continue; } if (classes.Any(x => x.Name == dto.Name || x.Abbreviation == dto.Abbreviation)) { sb.AppendLine(FailureMessage); continue; } var classToAdd = Mapper.Map <SeatingClass>(dto); classes.Add(classToAdd); sb.AppendLine(string.Format(SuccessMessage, dto.Name)); } context.SeatingClasses.AddRange(classes); context.SaveChanges(); return(sb.ToString().TrimEnd()); }
public static string ImportStations(StationsDbContext context, string jsonString) { var stationDtos = JsonConvert.DeserializeObject <StationDto[]>(jsonString); var sb = new StringBuilder(); var validStations = new List <Station>(); foreach (var stationDto in stationDtos) { bool exists = validStations.Any(s => s.Name == stationDto.Name); if (!IsValid(stationDto) || exists) { sb.AppendLine(ERROR_MESSAGE); continue; } stationDto.Town = stationDto.Town ?? stationDto.Name; var station = Mapper.Map <Station>(stationDto); validStations.Add(station); sb.AppendLine(string.Format(SuccessMessage, station.Name)); } context.Stations.AddRange(validStations); context.SaveChanges(); var result = sb.ToString(); return(result); }
public static string ImportCards(StationsDbContext context, string xmlString) { var serializer = new XmlSerializer(typeof(ImportDto.CardDto[]), new XmlRootAttribute("Cards")); ImportDto.CardDto[] deserializedCards = (ImportDto.CardDto[])serializer.Deserialize(new MemoryStream(Encoding.UTF8.GetBytes(xmlString))); StringBuilder sb = new StringBuilder(); List <CustomerCard> cards = new List <CustomerCard>(); foreach (var cardDto in deserializedCards) { if (!IsValid(cardDto)) { sb.AppendLine(FailureMessage); continue; } CustomerCard card = new CustomerCard() { Name = cardDto.Name, Age = cardDto.Age, Type = cardDto.CardType, }; cards.Add(card); sb.AppendLine(string.Format(SuccessMessage, cardDto.Name)); } context.AddRange(cards); context.SaveChanges(); return(sb.ToString().Trim()); }
public static string ImportCards(StationsDbContext context, string xmlString) { var sb = new StringBuilder(); var serializer = new XmlSerializer(typeof(CardDto[]), new XmlRootAttribute("Cards")); var deserializedCard = (CardDto[])serializer.Deserialize(new MemoryStream(Encoding.UTF8.GetBytes(xmlString))); var validCards = new List <CustomerCard>(); foreach (var dto in deserializedCard) { if (!IsValid(dto)) { sb.AppendLine(FailureMessage); continue; } var cardType = Enum.TryParse <CardType>(dto.CardType, out var cardT) ? cardT : CardType.Normal; var card = new CustomerCard { Name = dto.Name, Type = cardType, Age = dto.Age }; validCards.Add(card); sb.AppendLine(String.Format(SuccessMessage, $"{card.Name}")); } context.Cards.AddRange(validCards); context.SaveChanges(); return(sb.ToString()); }
public static string ImportStations(StationsDbContext context, string jsonString) { IEnumerable <Station> stations = JsonConvert.DeserializeObject <IEnumerable <Station> >(jsonString); var result = new StringBuilder(); foreach (Station station in stations) { if (string.IsNullOrEmpty(station.Town) || string.IsNullOrWhiteSpace(station.Town)) { station.Town = station.Name; } if (!IsValidStation(station, context)) { result.AppendLine(FailureMessage); } else { context.Stations.Add(station); context.SaveChanges(); result.AppendLine(String.Format(SuccessMessage, station.Name)); } } // context.SaveChanges(); return(result.ToString()); }
public static string ImportCards(StationsDbContext context, string xmlString) { XmlSerializer serializer = new XmlSerializer(typeof(CardImportDto[]), new XmlRootAttribute("Cards")); var cards = (CardImportDto[])serializer.Deserialize(new MemoryStream(Encoding.UTF8.GetBytes(xmlString))); List <CustomerCard> validCards = new List <CustomerCard>(); StringBuilder sb = new StringBuilder(); foreach (var card in cards) { if (!IsValid(card)) { sb.AppendLine(FailureMessage); continue; } CardType type = CardType.Normal; if (card.CardType != null) { type = Enum.Parse <CardType>(card.CardType); } CustomerCard customerCard = new CustomerCard(card.Name, card.Age, type); validCards.Add(customerCard); sb.AppendLine(string.Format(SuccessMessage, card.Name)); } context.Cards.AddRange(validCards); context.SaveChanges(); return(sb.ToString().TrimEnd()); }
public static string ImportStations(StationsDbContext context, string jsonString) { StationDto[] stationDtos = JsonConvert.DeserializeObject <StationDto[]>(jsonString); List <Station> stations = new List <Station>(); StringBuilder sb = new StringBuilder(); foreach (StationDto dto in stationDtos) { if (!IsValid(dto)) { sb.AppendLine(FailureMessage); continue; } if (stations.Any(s => s.Name == dto.Name)) { sb.AppendLine(FailureMessage); continue; } if (dto.Town == null) { dto.Town = dto.Name; } Station station = Mapper.Map <Station>(dto); stations.Add(station); sb.AppendLine(string.Format(SuccessMessage, dto.Name)); } context.Stations.AddRange(stations); context.SaveChanges(); return(sb.ToString().Trim()); }
public static string ImportClasses(StationsDbContext context, string jsonString) { SeatingClassDto[] classDtos = JsonConvert.DeserializeObject <SeatingClassDto[]>(jsonString); List <SeatingClass> seatingClasses = new List <SeatingClass>(); StringBuilder sb = new StringBuilder(); foreach (SeatingClassDto dto in classDtos) { if (!IsValid(dto)) { sb.AppendLine(FailureMessage); continue; } if (seatingClasses.Any(sc => sc.Name == dto.Name) || seatingClasses.Any(sc => sc.Abbreviation == dto.Abbreviation)) { sb.AppendLine(FailureMessage); continue; } SeatingClass seatingClass = Mapper.Map <SeatingClass>(dto); seatingClasses.Add(seatingClass); sb.AppendLine(string.Format(SuccessMessage, seatingClass.Name)); } context.SeatingClasses.AddRange(seatingClasses); context.SaveChanges(); return(sb.ToString().Trim()); }
public static string ImportCards(StationsDbContext context, string xmlString) { XmlSerializer serializer = new XmlSerializer(typeof(CardDto[]), new XmlRootAttribute("Cards")); CardDto[] cardDtos = (CardDto[])serializer.Deserialize(new StringReader(xmlString)); StringBuilder sb = new StringBuilder(); List <CustomerCard> cards = new List <CustomerCard>(); foreach (CardDto dto in cardDtos) { if (!IsValid(dto)) { sb.AppendLine(FailureMessage); continue; } CardType cardType = Enum.TryParse <CardType>(dto.CardType, out var card) ? card : CardType.Normal; CustomerCard customerCard = new CustomerCard { Name = dto.Name, Type = cardType, Age = dto.Age }; cards.Add(customerCard); sb.AppendLine(string.Format(SuccessMessage, customerCard.Name)); } context.Cards.AddRange(cards); context.SaveChanges(); return(sb.ToString().Trim()); }
public static string ImportClasses(StationsDbContext context, string jsonString) { var classes = new List <SeatingClass>(); var result = new StringBuilder(); var objClasses = JsonConvert.DeserializeObject <SeatingClass[]>(jsonString); foreach (var objClass in objClasses) { var ifClassExists = classes.Any(c => c.Name == objClass.Name || c.Abbreviation == objClass.Abbreviation); if (!IsValid(objClass) || ifClassExists) { result.AppendLine(FailureMessage); continue; } classes.Add(objClass); result.AppendLine(string.Format(SuccessMessage, objClass.Name)); } context.SeatingClasses.AddRange(classes); context.SaveChanges(); return(result.ToString()); }
public static string ImportStations(StationsDbContext context, string jsonString) { var stations = new List <Station>(); var result = new StringBuilder(); var objStations = JsonConvert.DeserializeObject <StationDto[]>(jsonString); foreach (var objStation in objStations) { var ifStationExists = stations.Any(s => s.Name == objStation.Name); if (!IsValid(objStation) || ifStationExists) { result.AppendLine(FailureMessage); continue; } if (objStation.Town == null) { objStation.Town = objStation.Name; } stations.Add(Mapper.Map <Station>(objStation)); result.AppendLine(string.Format(SuccessMessage, objStation.Name)); } context.AddRange(stations); context.SaveChanges(); return(result.ToString()); }
public static string ImportClasses(StationsDbContext context, string jsonString) { var sb = new StringBuilder(); var deserializedclasses = JsonConvert.DeserializeObject <SeatingClassDto[]>(jsonString); var validatedclasses = new List <SeatingClass>(); foreach (var sc in deserializedclasses) { if (!IsValid(sc)) { sb.AppendLine(FailureMessage); continue; } var seatingClassExists = validatedclasses.Any(e => e.Name == sc.Name || e.Abbreviation == sc.Abbreviation); if (seatingClassExists) { sb.AppendLine(FailureMessage); continue; } var seatingClass = AutoMapper.Mapper.Map <SeatingClass>(sc); sb.AppendLine(string.Format(SuccessMessage, seatingClass.Name)); validatedclasses.Add(seatingClass); } context.SeatingClasses.AddRange(validatedclasses); context.SaveChanges(); return(sb.ToString()); }
public static string ImportStations(StationsDbContext context, string jsonString) { List <Station> stations = JsonConvert.DeserializeObject <List <Station> >(jsonString); HashSet <string> stationNames = new HashSet <string>(); List <Station> validStations = new List <Station>(); StringBuilder sb = new StringBuilder(); foreach (var station in stations) { if (station.Town == null) { station.Town = station.Name; } if (!IsValid(station) || stationNames.Contains(station.Name)) { sb.AppendLine(FailureMessage); continue; } stationNames.Add(station.Name); validStations.Add(station); sb.AppendLine(string.Format(SuccessMessage, station.Name)); } context.Stations.AddRange(validStations); context.SaveChanges(); return(sb.ToString().TrimEnd()); }
public static string ImportCards(StationsDbContext context, string xmlString) { var serializer = new XmlSerializer(typeof(CardDto[]), new XmlRootAttribute("Cards")); var cardsFromXml = (CardDto[])serializer.Deserialize(new StringReader(xmlString)); var sb = new StringBuilder(); var resultCards = new List <CustomerCard>(); foreach (var cardDto in cardsFromXml) { if (!IsValid(cardDto)) { sb.AppendLine(FailureMessage); continue; } var type = Enum.Parse <CardType>(cardDto.CardType); var currentCard = new CustomerCard { Name = cardDto.Name, Age = cardDto.Age, Type = type }; resultCards.Add(currentCard); sb.AppendLine(string.Format(SuccessMessage, currentCard.Name)); } context.Cards.AddRange(resultCards); context.SaveChanges(); return(sb.ToString().Trim()); }
public static string ImportClasses(StationsDbContext context, string jsonString) { List <SeatingClass> seatingClasses = JsonConvert.DeserializeObject <List <SeatingClass> >(jsonString); HashSet <string> seatingClassNames = new HashSet <string>(); HashSet <string> abbreviations = new HashSet <string>(); List <SeatingClass> validSeatingClasses = new List <SeatingClass>(); StringBuilder sb = new StringBuilder(); foreach (var seatingClass in seatingClasses) { if (!IsValid(seatingClass) || seatingClassNames.Contains(seatingClass.Name) || abbreviations.Contains(seatingClass.Abbreviation)) { sb.AppendLine(FailureMessage); continue; } abbreviations.Add(seatingClass.Abbreviation); seatingClassNames.Add(seatingClass.Name); validSeatingClasses.Add(seatingClass); sb.AppendLine(string.Format(SuccessMessage, seatingClass.Name)); } context.SeatingClasses.AddRange(validSeatingClasses); context.SaveChanges(); return(sb.ToString().TrimEnd()); }
public static string ImportClasses(StationsDbContext context, string jsonString) { var seatingClassDtos = JsonConvert.DeserializeObject <List <SeatingClassImportDto> >(jsonString); var sb = new StringBuilder(); var seatingClassesToAdd = new List <SeatingClass>(); foreach (var seatingClassDto in seatingClassDtos) { if (!IsValid(seatingClassDto)) { sb.AppendLine(FailureMessage); continue; } if (seatingClassesToAdd.Any(sc => sc.Name == seatingClassDto.Name || sc.Abbreviation == seatingClassDto.Abbreviation)) { sb.AppendLine(FailureMessage); continue; } var seatingClass = Mapper.Map <SeatingClass>(seatingClassDto); seatingClassesToAdd.Add(seatingClass); sb.AppendLine(string.Format(SuccessMessage, seatingClass.Name)); } context.SeatingClasses.AddRange(seatingClassesToAdd); context.SaveChanges(); var result = sb.ToString().Trim(); return(result); }
public static string ImportStations(StationsDbContext context, string jsonString) { var result = new List <string>(); var objects = JsonConvert.DeserializeObject <StationDto[]>(jsonString); var stationsToImport = new List <Station>(); foreach (var o in objects) { if (o.Town == null) { o.Town = o.Name; } if (o.Name == null || o.Name.Length > 50 || o.Town.Length > 50 || stationsToImport.Any(s => s.Name == o.Name)) { result.Add(FailureMessage); continue; } stationsToImport.Add(new Station { Name = o.Name, Town = o.Town }); result.Add(String.Format(SuccessMessage, o.Name)); } context.Stations.AddRange(stationsToImport); context.SaveChanges(); return(String.Join(Environment.NewLine, result)); }
public static string ImportStations(StationsDbContext context, string jsonString) { var sb = new StringBuilder(); var stations = JsonConvert.DeserializeObject <StationDto[]>(jsonString); var stationsToAdd = new List <Station>(); foreach (var stationDto in stations) { if (stationDto.Town == null && stationDto.Name != null) { stationDto.Town = stationDto.Name; } if (stationDto.Name == null || stationDto.Name.Length > 50 || stationDto.Town.Length > 50 || stationsToAdd.Any(s => s.Name == stationDto.Name)) { sb.AppendLine(FailureMessage); continue; } var stationToAdd = Mapper.Map <Station>(stationDto); stationsToAdd.Add(stationToAdd); sb.AppendLine(string.Format(SuccessMessage, stationDto.Name)); } context.Stations.AddRange(stationsToAdd); context.SaveChanges(); return(sb.ToString().TrimEnd()); }
public static string ImportClasses(StationsDbContext context, string jsonString) { var result = new List <string>(); var classesToImport = new List <SeatingClass>(); var objects = JsonConvert.DeserializeAnonymousType(jsonString, new[] { new { Name = String.Empty, Abbreviation = String.Empty } }); foreach (var o in objects) { if (classesToImport.Any(c => c.Name == o.Name) || classesToImport.Any(c => c.Abbreviation == o.Abbreviation) || o.Abbreviation == null || o.Name == null || o.Name.Length > 30 || o.Abbreviation.Length != 2) { result.Add(FailureMessage); continue; } classesToImport.Add(new SeatingClass { Name = o.Name, Abbreviation = o.Abbreviation }); result.Add(String.Format(SuccessMessage, o.Name)); } context.SeatingClasses.AddRange(classesToImport); context.SaveChanges(); return(String.Join(Environment.NewLine, result)); }
public static string ImportCards(StationsDbContext context, string xmlString) { var serializer = new XmlSerializer(typeof(CardDto[]), new XmlRootAttribute("Cards")); var carDtos = (CardDto[])serializer.Deserialize(new StringReader(xmlString)); var sb = new StringBuilder(); var validCards = new List <CustomerCard>(); foreach (var cardDto in carDtos) { if (!IsValid(cardDto)) { sb.AppendLine(ERROR_MESSAGE); continue; } var cardType = Enum.Parse <CardType>(cardDto.CardType); var card = Mapper.Map <CustomerCard>(cardDto); card.Type = cardType; validCards.Add(card); sb.AppendLine(string.Format(SuccessMessage, card.Name)); } context.Cards.AddRange(validCards); context.SaveChanges(); var result = sb.ToString(); return(result); }
public static string ImportCards(StationsDbContext context, string xmlString) { StringBuilder sb = new StringBuilder(); var serializer = new XmlSerializer(typeof(CustomerCard), new XmlRootAttribute("cards")); var deserializedCards = (CustomerCard[])serializer.Deserialize(new MemoryStream(Encoding.UTF8.GetBytes(xmlString))); List <CustomerCard> cards = new List <CustomerCard>(); foreach (var card in deserializedCards) { if (!IsValid(card)) { sb.AppendLine(FailureMessage); continue; } var cardType = Enum.TryParse <CardType>(card.Type.ToString(), out var card1) ? card1 : CardType.Normal; var customCard = new CustomerCard() { Name = card.Name, Type = cardType, Age = card.Age }; cards.Add(customCard); sb.AppendLine(string.Format(SuccessMessage, customCard.Name)); } context.Cards.AddRange(cards); context.SaveChanges(); return(sb.ToString()); }
public static string ImportClasses(StationsDbContext context, string jsonString) { var classDtos = JsonConvert.DeserializeObject <SeatingClassDto[]>(jsonString); var sb = new StringBuilder(); var validClasses = new List <SeatingClass>(); foreach (var classDto in classDtos) { bool exists = validClasses.Any(c => c.Name == classDto.Name || c.Abbreviation == classDto.Abbreviation); if (!IsValid(classDto) || exists) { sb.AppendLine(ERROR_MESSAGE); continue; } var seatingClass = Mapper.Map <SeatingClass>(classDto); validClasses.Add(seatingClass); sb.AppendLine(string.Format(SuccessMessage, seatingClass.Name)); } context.SeatingClasses.AddRange(validClasses); context.SaveChanges(); var result = sb.ToString(); return(result); }
public static string ImportClasses(StationsDbContext context, string jsonString) { StringBuilder sb = new StringBuilder(); var deserializedClasses = JsonConvert.DeserializeObject <SeatingClass[]>(jsonString); List <SeatingClass> classes = new List <SeatingClass>(); foreach (var clas in deserializedClasses) { if (!IsValid(clas)) { sb.AppendLine(FailureMessage); continue; } var seatingClassAlreadyExists = classes .Any(sc => sc.Name == clas.Name || sc.Abbreviation == clas.Abbreviation); if (seatingClassAlreadyExists) { sb.AppendLine(FailureMessage); continue; } var seatClass = new SeatingClass() { Name = clas.Name, Abbreviation = clas.Abbreviation }; classes.Add(seatClass); sb.AppendLine(String.Format(SuccessMessage, seatClass.Name)); } context.SeatingClasses.AddRange(classes); context.SaveChanges(); return(sb.ToString()); }
public static string ImportStations(StationsDbContext context, string jsonString) { var sb = new StringBuilder(); var deserializedStations = JsonConvert.DeserializeObject <StationDto[]>(jsonString); var validStations = new List <Station>(); foreach (var stationDto in deserializedStations) { if (!IsValid(stationDto) || validStations.Any(s => s.Name == stationDto.Name)) { sb.AppendLine(FailureMessage); continue; } var station = Mapper.Map <Station>(stationDto); if (stationDto.Town == null) { station.Town = stationDto.Name; } validStations.Add(station); sb.AppendLine(string.Format(SuccessMessage, stationDto.Name)); } context.Stations.AddRange(validStations); context.SaveChanges(); return(sb.ToString()); }
public static string ImportClasses(StationsDbContext context, string jsonString) { var seatinClasses = JsonConvert.DeserializeObject <SeatingClass[]>(jsonString); StringBuilder sb = new StringBuilder(); List <SeatingClass> validSeatingClasses = new List <SeatingClass>(); foreach (var seatingClass in seatinClasses) { if (!IsValid(seatingClass)) { sb.AppendLine(FailureMessage); continue; } var iSeatingClassExist = context.SeatingClasses.Any(x => x.Name == seatingClass.Name || x.Abbreviation == seatingClass.Abbreviation); if (iSeatingClassExist || validSeatingClasses.Any(x => x.Name == seatingClass.Name || x.Abbreviation == seatingClass.Abbreviation)) { sb.AppendLine(FailureMessage); continue; } validSeatingClasses.Add(seatingClass); sb.AppendLine(string.Format(SuccessMessage, seatingClass.Name)); } context.SeatingClasses.AddRange(validSeatingClasses); context.SaveChanges(); return(sb.ToString().TrimEnd()); }
public static string ImportClasses(StationsDbContext context, string jsonString) { StringBuilder sb = new StringBuilder(); SeatingClassDto[] deserializedClasses = JsonConvert.DeserializeObject <SeatingClassDto[]>(jsonString); List <SeatingClass> validClasses = new List <SeatingClass>(); foreach (SeatingClassDto seatingClassDto in deserializedClasses) { if (!IsValid(seatingClassDto)) { sb.AppendLine(FailureMessage); continue; } Boolean classAlreadyExist = validClasses.Any(c => c.Name == seatingClassDto.Name || c.Abbreviation == seatingClassDto.Abbreviation); if (classAlreadyExist) { sb.AppendLine(FailureMessage); continue; } SeatingClass seatingClass = Mapper.Map <SeatingClass>(seatingClassDto); validClasses.Add(seatingClass); sb.AppendLine(string.Format(SuccessMessage, seatingClassDto.Name)); } context.SeatingClasses.AddRange(validClasses); context.SaveChanges(); string result = sb.ToString(); return(result); }
public static string ImportClasses(StationsDbContext context, string jsonString) { SeatingClass[] classesFromJson = ImportFromJson <SeatingClass>(jsonString, false); StringBuilder sb = new StringBuilder(); List <SeatingClass> resultClasses = new List <SeatingClass>(); foreach (SeatingClass seatingClass in classesFromJson) { if (!IsValid(seatingClass)) { sb.AppendLine(FailureMessage); continue; } if (resultClasses.Any(c => c.Name == seatingClass.Name || c.Abbreviation == seatingClass.Abbreviation)) { sb.AppendLine(FailureMessage); continue; } resultClasses.Add(seatingClass); sb.AppendLine(string.Format(SuccessMessage, seatingClass.Name)); } context.SeatingClasses.AddRange(resultClasses); context.SaveChanges(); string result = sb.ToString().Trim(); return(result); }