/// <summary> /// Create a new TpTreaty object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="hostCountryId">Initial value of the HostCountryId property.</param> /// <param name="partnerCountryId">Initial value of the PartnerCountryId property.</param> public static TpTreaty CreateTpTreaty(global::System.Int32 id, global::System.Int32 hostCountryId, global::System.Int32 partnerCountryId) { TpTreaty tpTreaty = new TpTreaty(); tpTreaty.Id = id; tpTreaty.HostCountryId = hostCountryId; tpTreaty.PartnerCountryId = partnerCountryId; return tpTreaty; }
/// <summary> /// Deprecated Method for adding a new object to the TpTreaties EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToTpTreaties(TpTreaty tpTreaty) { base.AddObject("TpTreaties", tpTreaty); }
private IEnumerable<PublisherStatus> PublishContent(DataRowCollection contentRows, string sheetName) { var allStatus = new List<PublisherStatus>(); if (contentRows.Count >= 1) { using (var work = new UnitOfWork()) { var countryRepo = RepositoryContainer.GetRepository<Nest.DataAccess.Country>(work); var tpTreatyRepo = RepositoryContainer.GetRepository<Nest.DataAccess.TpTreaty>(work); var allCountries = countryRepo.All().ToList(); var dbHostCountry = allCountries.FirstOrDefault(b => b.Name == contentRows[0].ItemArray[0].ToString().Trim()); var removeCountryList = tpTreatyRepo.Delete(b => b.HostCountryId == dbHostCountry.Id); var metaInfo = contentRows[0]; if(dbHostCountry == null) { allStatus.Add(new PublisherStatus() { Message = "Host Country Name Doesn't Exist In DataBase" ,Status = false}); allStatus.Add(new PublisherStatus { Status = false, Message = "Data uploading failed for sheet " + sheetName }); return allStatus; } //var conceptIdExistStatus = CheckConceptIdInfo(contentRows); //var idExistStatus = conceptIdExistStatus.ToList(); //allStatus.AddRange(idExistStatus); //if (idExistStatus.Any(b => b.Status == false)) //{ // allStatus.Add(new PublisherStatus // { // Status = false, // Message = "Data uploading failed for sheet " + sheetName // }); // return allStatus; //} HostCountry = dbHostCountry; if (contentRows.Count >= 2) { for (var index = 1; index < contentRows.Count; index++) { if(string.IsNullOrEmpty(contentRows[index].ItemArray[0].ToString().Trim()))continue; var dbPartenerCountry = allCountries.FirstOrDefault(b => b.Name == contentRows[index].ItemArray[0].ToString().Trim()); if (dbPartenerCountry == null) { allStatus.Add(new PublisherStatus() { Message = "Partner Country Name " + contentRows[index].ItemArray[0].ToString().Trim() + " Doesn't Exist In DataBase", Status = false }); } if (dbPartenerCountry != null) { var dbTpTreaty = tpTreatyRepo.Filter(b => b.HostCountryId == dbHostCountry.Id && b.PartnerCountryId == dbPartenerCountry.Id).FirstOrDefault(); if (dbTpTreaty == null) { dbTpTreaty = new Nest.DataAccess.TpTreaty(); tpTreatyRepo.Add(dbTpTreaty); } dbTpTreaty.HostCountryId = dbHostCountry.Id; dbTpTreaty.PartnerCountryId = dbPartenerCountry.Id; dbTpTreaty.OcdeArt1 = contentRows[index].ItemArray[1].ToString().Trim().Equals("None", StringComparison.InvariantCultureIgnoreCase) ? null : contentRows[index].ItemArray[1].ToString().Trim(); dbTpTreaty.OcdeArt2 = contentRows[index].ItemArray[2].ToString().Trim().Equals("None", StringComparison.InvariantCultureIgnoreCase) ? null : contentRows[index].ItemArray[2].ToString().Trim(); dbTpTreaty.ReliefFromDouble = contentRows[index].ItemArray[3].ToString().Trim().Equals("None", StringComparison.InvariantCultureIgnoreCase) ? null : contentRows[index].ItemArray[3].ToString().Trim(); dbTpTreaty.CompetentAuthority = contentRows[index].ItemArray[4].ToString().Trim().Equals("None", StringComparison.InvariantCultureIgnoreCase) ? null : contentRows[index].ItemArray[4].ToString().Trim(); dbTpTreaty.OcdeArt3 = contentRows[index].ItemArray[5].ToString().Trim().Equals("None", StringComparison.InvariantCultureIgnoreCase) ? null : contentRows[index].ItemArray[5].ToString().Trim(); dbTpTreaty.OcdeArt1_ConceptId = contentRows[index].ItemArray[1].ToString().Trim().Length > 0 && contentRows[index].ItemArray[1].ToString().Trim().ToLower() != "None".ToLower() ? metaInfo.ItemArray[1].ToString().Trim() : null; dbTpTreaty.OcdeArt2_ConceptId = contentRows[index].ItemArray[2].ToString().Trim().Length > 0 && contentRows[index].ItemArray[2].ToString().Trim().ToLower() != "None".ToLower() ? metaInfo.ItemArray[2].ToString().Trim() : null; dbTpTreaty.ReliefFromDouble_ConceptId = contentRows[index].ItemArray[3].ToString().Trim().Length > 0 && contentRows[index].ItemArray[3].ToString().Trim().ToLower() != "None".ToLower() ? metaInfo.ItemArray[3].ToString().Trim() : null; dbTpTreaty.CompetentAuthority_ConceptId = contentRows[index].ItemArray[4].ToString().Trim().Length > 0 && contentRows[index].ItemArray[4].ToString().Trim().ToLower() != "None".ToLower() ? metaInfo.ItemArray[4].ToString().Trim() : null; dbTpTreaty.OcdeArt3_ConceptId = contentRows[index].ItemArray[5].ToString().Trim().Length > 0 && contentRows[index].ItemArray[5].ToString().Trim().ToLower() != "None".ToLower() ? metaInfo.ItemArray[5].ToString().Trim() : null; } } if(allStatus.Any(b => b.Status == false) == false) { work.SaveChanges(); allStatus.Add(new PublisherStatus() { Message = "Data uploaded sucessfully for sheet " + sheetName ,Status = true}); } else { allStatus.Add(new PublisherStatus { Status = false, Message = "Data uploading failed for sheet " + sheetName }); } } } } return allStatus; }