protected void Button2Click(object sender, EventArgs e) { MembershipUser user = Membership.GetUser(); if (user != null) { var userKey = user.ProviderUserKey; if (userKey != null) { var userID = (Guid) userKey; using (var context2 = new AdDatabaseModel.AdDatabaseEntities()) context2.AddTempAd(Helpers.Utility.GetTempAdID(), 2, 3, 4, "Http://www.google.com", 3, "imageurl", "text", "Home", 200, 300, 100, Convert.ToDateTime(DateTime.Now.ToString(CultureInfo.InvariantCulture)), Convert.ToDateTime(DateTime.Now.ToString(CultureInfo.InvariantCulture)), userID, 1, 2, 3,256, "usa",128,"OverlandPark",null,null, "zipcode", 300, 4, "Painter,Mechanic,doctor,eletrician", Convert.ToDateTime(DateTime.Now.ToString(CultureInfo.InvariantCulture)), "adName", 3, "US", Helpers.Utility.GetFlagPath(256), "5,15,20,74"); //context2.AddTempAd( 2, "facebook.com", 2, 3, "http://www.google.com", 2, "imageurl", // "alternativetext", "keyword", 50, 200, 700, // Convert.ToDateTime(DateTime.Now.ToString(CultureInfo.InvariantCulture)) // , Convert.ToDateTime(DateTime.Now.ToString(CultureInfo.InvariantCulture)), // false, // userID, 1, 1, 1, "country", 200, "code", "region", "city", "zipcode", 2, 4, // "Painter,Electrician,doctor,Mecanic", // Convert.ToDateTime(DateTime.Now.ToString(CultureInfo.InvariantCulture)) // , 5, "adName"); } } }
protected void CheckingUpdateActiveCompaingToComplete() { using (var context = new AdDatabaseModel.AdDatabaseEntities()) { DateTime start = DateTime.Today; start = start.AddDays(-1); var activeCompaing = (from c in context.AdGenerals where c.EndDate < start orderby c.EndDate select c).ToList(); foreach (var t in activeCompaing) { Response.Write("ID"); Response.Write(t.ID); Response.Write("------ "); Response.Write("EndDate"); Response.Write(t.EndDate.ToString(CultureInfo.InvariantCulture)); Response.Write("Yesterday"); Response.Write(start.Date.ToString(CultureInfo.InvariantCulture)); Response.Write("------ "); Response.Write("ISActive"); Response.Write(t.IsActive); Response.Write("------ "); Response.Write("Complete"); Response.Write(t.Completed); Response.Write("------ "); Response.Write("<br/>"); } context.SaveChanges(); } }
protected void GetAdProperties() { int y = GetTempAdID(); using (var context2 = new AdDatabaseModel.AdDatabaseEntities()) { var adList = (from ad in context2.TempAds where ad.ID == y select ad).ToList(); NewCampaingTextBox.Text = Convert.ToString(adList[0].AdName); NewCampaingTextBox.ReadOnly = true; SiteDropDownList.SelectedIndex = Convert.ToInt32(adList[0].SiteID); SiteDropDownList.Enabled = false; SectionDropDownList.SelectedIndex = Convert.ToInt32(adList[0].SectionID); SectionDropDownList.Enabled = false; LanguageDropDownList.SelectedIndex = Convert.ToInt32(adList[0].LanguageID); LanguageDropDownList.Enabled = false; GenderDropDownList.SelectedIndex = Convert.ToInt32(adList[0].GenderID); GenderDropDownList.Enabled = false; AgeDropDownList.SelectedIndex = Convert.ToInt32(adList[0].AgeRangeID); AgeDropDownList.Enabled = false; CountryDropDownList.SelectedValue = Convert.ToInt32(adList[0].CountryID).ToString(CultureInfo.InvariantCulture); CountryDropDownList.Enabled = false; CountryDropDownList.DataBind(); RegionsDropDownList.SelectedValue = Convert.ToInt32(adList[0].RegionID).ToString(CultureInfo.InvariantCulture); RegionsDropDownList.Enabled = false; RegionsDropDownList.DataBind(); var id = adList[0].CityID; if (id != null) { CitiesDropDownList.SelectedIndex = Convert.ToInt32(adList[0].CityID); } else { CitiesDropDownList.SelectedIndex = -1; } CitiesDropDownList.Enabled = false; ZipcodeTextBox.Text = Convert.ToString(adList[0].Zipcode.ToString(CultureInfo.InvariantCulture)); ZipcodeTextBox.ReadOnly = true; IndustryDropDownList.SelectedIndex = Convert.ToInt32(adList[0].IndustryID); IndustryDropDownList.Enabled = false; ProfessionTextBox.Text = Convert.ToString(adList[0].Profession.ToString(CultureInfo.InvariantCulture)); ProfessionTextBox.ReadOnly = true; StartDateTextBox.Text = adList[0].StartDate.ToShortDateString(); EndDateTextBox.Text = adList[0].EndDate.ToShortDateString(); } }
protected void Page_Load(object sender, EventArgs e) { //GridView1.DataSource = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.Authenticated); //GridView1.DataBind(); // Roles.GetUsersInRole("RoleName"); using (var context = new AdDatabaseModel.AdDatabaseEntities()) { var result = from c in context.aspnet_Users select c; var t = result.FirstOrDefault(); } // ProfileCommon profile = (ProfileCommon)ProfileBase.Create("Tim", true); var membershipProvider1 = Membership.Providers["MembershipProvider1"]; var test = membershipProvider1.GetUser("Tim", false); var profile = Profile.GetProfile("Tim"); var muc = Roles.GetUsersInRole("Advertiser").Select(Membership.GetUser).ToList(); // var muc = Membership.GetAllUsers(); List<object> profileList = (from MembershipUser mu in muc select Profile.GetProfile(mu.UserName)) .Cast<object>() .ToList(); var profileList2 = new List<CustomProfileList>(); foreach (var i in profileList) { profileList2.Add(new CustomProfileList (((ProfileCommon)(i)).FirstName + "," + ((ProfileCommon)(i)).LastName, ((ProfileCommon)(i)).Gender, ((ProfileCommon)(i)).CountryID.ToString() + "," + ((ProfileCommon)(i)).RegionID + "," + ((ProfileCommon)(i)).CityID + "," + ((ProfileCommon)(i)).Zipcode, ((ProfileCommon)(i)).ProfessionID, ((ProfileCommon)(i)).Age, ((ProfileCommon)(i)).Email, ((ProfileCommon)(i)).Language, ((ProfileCommon)(i)).LCID, ((ProfileCommon)(i)).Cellphone, ((ProfileCommon)(i)).Picture1, ((ProfileCommon)(i)).LastActivityDate, ((ProfileCommon)(i)).UserName)); } //GridView1.DataSource = profileList; // GridView1.DataBind(); GridView1.DataSource = profileList2; GridView1.DataBind(); }
private static void CleanTempAd() { int count = 0; using (var context = new AdDatabaseModel.AdDatabaseEntities()) { DateTime start = DateTime.Today; start = start.AddDays(-7); var tempAd = (from c in context.TempAds where c.DateCreated < start orderby c.DateCreated select c).ToList(); foreach (var t in tempAd) { context.TempAds.DeleteObject(t); count++; } context.SaveChanges(); string subject = "Advertise Schedule Routing" + DateTime.Now.ToUniversalTime(); string body = "Number of records:" + count; SendEmail(subject, body); } }
protected void Button1Click(object sender, EventArgs e) { MembershipUser user = Membership.GetUser(); if (user != null) { var userKey = user.ProviderUserKey; if (userKey != null) { var userID = (Guid)userKey; using (var context2 = new AdDatabaseModel.AdDatabaseEntities()) context2.CreateNewAd(1, 1, 1, "yahoo.com", 1, "../Advertiser/Ads/Ad1.gif", "hello ther", "keyword", 55, 50, 100, Convert.ToDateTime(DateTime.Now.ToString(CultureInfo.InvariantCulture)), Convert.ToDateTime(DateTime.Now.ToString(CultureInfo.InvariantCulture)), false, userID, 1, 1, 1, 256, "USA", 126, "Overland", null, null, "66203", 25, "Profession", Convert.ToDateTime(DateTime.Now.ToString(CultureInfo.InvariantCulture)), Helpers.Utility.GetAudienceAdID(), "AdName", 2,"US", Helpers.Utility.GetFlagPath(256), "5,15,20,74"); } } }
protected void UpdateAd(string adPath, int action) { //Set Active to false //When Payment is complete //Set Active to true ////////////////////Currently; providing regular compaing:Type 1///////////////// //If sponsorship arise in the feature, then will need to implement other adType const int adTypeID = 1; using (var context = new AdDatabaseModel.AdDatabaseEntities()) try { context.UpdateempAd(GetAdID(), SiteDropDownList.SelectedIndex, SectionDropDownList.SelectedIndex, PositionDropDownList.SelectedIndex, GetDestinationURL(), FormatDropDownList.SelectedIndex, adPath, AlternativeText(), GetKeywordString(), Helpers.Utility.GetImpression(SpecialityListBox1, SpecialityListBox2, SpecialityListBox3), GetCreativeWidth(FormatDropDownList.SelectedIndex), GetCreativeHeight(FormatDropDownList.SelectedIndex), GetStartDate(), GetEndDate(), GetUserID(), LanguageDropDownList.SelectedIndex, GenderDropDownList.SelectedIndex, AgeDropDownList.SelectedIndex, Convert.ToInt32(CountryDropDownList.SelectedValue), CountryDropDownList.SelectedItem.Text, Convert.ToInt32(RegionsDropDownList.SelectedValue), RegionsDropDownList.SelectedItem.Text, CitiesDropDownList.SelectedIndex, GetCityName(), Helpers.Utility.GetZipcode(Convert.ToInt32(CountryDropDownList.SelectedValue), Convert.ToInt32(RegionsDropDownList.SelectedValue), GetCityName(), ZipcodeTextBox.Text), IndustryDropDownList.SelectedIndex, Helpers.Utility.GetNumberOfProfession(SpecialityListBox1, SpecialityListBox2, SpecialityListBox3), Helpers.Utility.GetProfession(SpecialityListBox1, SpecialityListBox2, SpecialityListBox3), Convert.ToDateTime(DateTime.Now.ToString(CultureInfo.InvariantCulture)), NewCampaingTextBox.Text, adTypeID, Helpers.Utility.GetCountryCode(Convert.ToInt32(CountryDropDownList.SelectedValue)), Helpers.Utility.GetFlagPath(Convert.ToInt32(CountryDropDownList.SelectedValue)), Helpers.Utility.GetProfessionID(SpecialityListBox1, SpecialityListBox2, SpecialityListBox3),action); } catch (Exception e) { } }
protected double PaymentDue() { //Formual Prospective //Sections * Industry * Profession * Date //Current Forumla //Profession * date double professionPrice = 50; int y = GetTempAdID(); using (var context2 = new AdDatabaseModel.AdDatabaseEntities()) { var tempad = (from ad in context2.TempAds where ad.ID == y select ad).FirstOrDefault(); int numberofprofession = int.Parse(tempad.NumberofProfession.ToString(CultureInfo.InvariantCulture)); int numberofdays = (int)(tempad.EndDate - tempad.StartDate).TotalDays; double amount = numberofprofession * numberofdays * professionPrice; if (amount.Equals(0)) { if ( numberofprofession == 0) { var number = ProfessionTextBox.Text; int numberofprofession2 = number.Count(f => f == ','); numberofprofession = numberofprofession2 == 0 ? 1 : numberofprofession2; } else if (numberofdays == 0) { numberofdays = 1; } } amount = numberofprofession * numberofdays * professionPrice; if (amount.Equals(0)) { amount = professionPrice; } return amount; } }
protected void GetAdProperties() { int y = GetAdID(); using (var context2 = new AdDatabaseModel.AdDatabaseEntities()) { var adList = (from ad in context2.TempAds where ad.ID == y select ad).ToList(); NewCampaingTextBox.Text = Convert.ToString(adList[0].AdName); SiteDropDownList.SelectedIndex = Convert.ToInt32(adList[0].SiteID); SectionDropDownList.SelectedIndex = Convert.ToInt32(adList[0].SectionID); PositionDropDownList.SelectedIndex = Convert.ToInt32(adList[0].PositionID); DestinationURLTextBox.Text = Convert.ToString(adList[0].NavigateUrl); FormatDropDownList.SelectedIndex = Convert.ToInt32(adList[0].FormatID); AlternativeTextTextBox.Text = Convert.ToString(adList[0].AlternateText); LanguageDropDownList.SelectedIndex = Convert.ToInt32(adList[0].LanguageID); GenderDropDownList.SelectedIndex = Convert.ToInt32(adList[0].GenderID); AgeDropDownList.SelectedIndex = Convert.ToInt32(adList[0].AgeRangeID); CountryDropDownList.SelectedValue = Convert.ToInt32(adList[0].CountryID).ToString(CultureInfo.InvariantCulture); CountryDropDownList.DataBind(); RegionsDropDownList.SelectedValue = Convert.ToInt32(adList[0].RegionID).ToString(CultureInfo.InvariantCulture); RegionsDropDownList.DataBind(); var id = adList[0].CityID; if (id != null) { CitiesDropDownList.SelectedIndex = Convert.ToInt32(adList[0].CityID); } else { CitiesDropDownList.SelectedIndex = -1; } ZipcodeTextBox.Text = Convert.ToString(adList[0].Zipcode.ToString(CultureInfo.InvariantCulture)); IndustryDropDownList.SelectedIndex = Convert.ToInt32(adList[0].IndustryID); IndustryDropDownList.DataBind(); SpecialityListBox1.DataBind(); SpecialityListBox2.DataBind(); SpecialityListBox3.DataBind(); string[] professions = Convert.ToString(adList[0].ProfessionID).Split(','); foreach (var profession in professions) { SelectProfession(profession); } StartDateCalendar.SelectedDate = (Convert.ToDateTime(adList[0].StartDate)).Date; EndDateCalendar.SelectedDate = (Convert.ToDateTime(adList[0].EndDate)).Date; } }
protected void Sum(DateTime? t1, DateTime? t2) { using (var context = new AdDatabaseModel.AdDatabaseEntities()) { Guid id = Utility.GetGuidUserID(); var totalHit = 0; var totalClick = 0; var y = (from g in context.AdGenerals join s in context.AdTotalStats on g.AdID equals s.AdId where g.UserID == id && (bool) g.Completed && (!g.IsActive) select new AdvertiserReport { ID = g.AdID, ImageUrl = g.ImageUrl, StartDate = g.StartDate, EndDate = g.EndDate, IsActive = g.IsActive, TotalImpression = (int)s.TotalImpression, TotalClick = (int)s.TotalClick, AdName = g.AdName }).ToList(); if (!(t1 == null || t2 == null)) { y = (from g in context.AdGenerals join s in context.AdTotalStats on g.AdID equals s.AdId where g.StartDate >= t2 && g.EndDate <= t1 && g.UserID == id && (bool)g.Completed && (!g.IsActive) select new AdvertiserReport { ID = g.AdID, ImageUrl = g.ImageUrl, StartDate = g.StartDate, EndDate = g.EndDate, IsActive = g.IsActive, TotalImpression = (int)s.TotalImpression, TotalClick = (int)s.TotalClick, AdName = g.AdName }).ToList(); } foreach (var x in y) { totalHit += x.TotalImpression; totalClick += x.TotalClick; } TotalHits.Text = totalHit.ToString(CultureInfo.InvariantCulture); TotalClicks.Text = totalClick.ToString(CultureInfo.InvariantCulture); if (y.Count == 0) { StartDate.Text = String.Format("{0:MM/dd/yyyy}", t2); EndDate.Text = String.Format("{0:MM/dd/yyyy}", t1); AverageHit.Text = Resource.Zero; AverageClick.Text = Resource.Zero; } else { //Retrieve Minimum Date var minDate = (from d in y select d.StartDate).Min(); StartDate.Text = minDate.ToShortDateString(); //Retrieve Maximum Date var maxDate = (from d in y select d.EndDate).Max(); EndDate.Text = maxDate.ToShortDateString(); var numberofDays = (maxDate - minDate).TotalDays; AverageHit.Text = Math.Round((totalHit / numberofDays), 2).ToString(CultureInfo.InvariantCulture); AverageClick.Text = Math.Round((totalClick / numberofDays), 2).ToString(CultureInfo.InvariantCulture); } } }
protected void Payment() { var context = new AdDatabaseModel.AdDatabaseEntities(); //If exisiting Payment Exist //PaymentDue var advertiserPaymentDue = new AdDatabaseModel.AdvertiserPaymentDue { AdvertiserID = GetUserID(), PaymentDueID = Helpers.Utility.GetPaymentID(), AdID = GetTempAdID(), AdAmount = PaymentDue(), Date = DateTime.Now.Date, CurrencyCode = "USA", PaymentDue = PaymentDue(), Status = Resources.Resource.Pending.ToString(CultureInfo.InvariantCulture), PaymentProcess = false }; context.AddToAdvertiserPaymentDues(advertiserPaymentDue); context.SaveChanges(); }
protected void SaveAd() { int y = GetTempAdID(); using (var context2 = new AdDatabaseModel.AdDatabaseEntities()) { var tempad = (from ad in context2.TempAds where ad.ID == y select ad).FirstOrDefault(); context2.CreateNewAd(tempad.SiteID, tempad.SectionID, tempad.PositionID, tempad.NavigateUrl, tempad.FormatID, tempad.ImageUrl, tempad.AlternateText, tempad.Keyword, tempad.Impressions, tempad.Width, tempad.Height, tempad.StartDate, tempad.EndDate , false, GetUserID(), tempad.LanguageID, tempad.GenderID, tempad.AgeRangeID, tempad.CountryID, tempad.CountryName, tempad.RegionID, tempad.RegionName, tempad.CityID, tempad.CityName, tempad.Zipcode, tempad.IndustryID, tempad.Profession, tempad.DateCreated, GetTempAdID(), tempad.AdName, tempad.AdTypeID, tempad.CountryCode, tempad.FlagPath, tempad.ProfessionID); } }
public static int GetPaymentID() { int paymentID; var context = new AdDatabaseModel.AdDatabaseEntities(); var max = context.AdvertiserPaymentDues.OrderByDescending(s => s.PaymentDueID).FirstOrDefault(); if (max == null) { paymentID = 0; } else { paymentID = max.PaymentDueID + 1; } return paymentID; }
public static void UpdateImpression(int adId, DateTime entryData, int type, string iPAddress, string countryCode, string region, string postalcode, int areaCode, int metroCode, double latitude, double longitude, string refURL, string browserType, string browserName, string browserPlatform, string userHostAddress, string userHostName, string userLanguage, string mobileDeviceManufacturer, string mobileDeviceModel, string deviceType, int userId, string userRole, string firstName, string lastName, string address, int countryID, string countryName, int regionID, string regionName, int cityID, string cityName, string phone, int age, int gender, string emailAddress, string photoPath, int industryID, int professionID, int lcid) { using (var context = new AdDatabaseModel.AdDatabaseEntities()) context.UpdateAdStatistic(adId, entryData, type, iPAddress, countryCode, region, postalcode, areaCode, metroCode, latitude, longitude, refURL, browserType, browserName, browserPlatform, userHostAddress, userHostName, userLanguage, mobileDeviceManufacturer, mobileDeviceModel, deviceType, userId, userRole, firstName, lastName, address, countryID, countryName, regionID, regionName, cityID, cityName, phone, age, gender, emailAddress, photoPath, industryID, professionID, lcid); }
public static int GetNextSuccessfulPDTID() { int ID; var context = new AdDatabaseModel.AdDatabaseEntities(); var max = context.AdvertiserSuccessfulPDTs.OrderByDescending(s => s.PDTID).FirstOrDefault(); if (max == null) { ID = 0; } else { ID = max.PDTID + 1; } return ID; }
public static int GetTempAdID() { int adID; var context = new AdDatabaseModel.AdDatabaseEntities(); var max = context.TempAds.OrderByDescending(s => s.ID).FirstOrDefault(); if (max == null) { adID = 0; } else { adID = max.ID + 1; } return adID; }
private static void UpdateActiveCompaingToComplete() { using (var context = new AdDatabaseModel.AdDatabaseEntities()) { DateTime start = DateTime.Today; start = start.AddDays(-1); var activeCompaing = (from c in context.AdGenerals where c.EndDate <= start && c.IsActive orderby c.EndDate select c).ToList(); foreach (var t in activeCompaing) { t.IsActive = false; t.Completed = true; } context.SaveChanges(); } }
public static string GetSectionNameByID( int id) { using (var context = new AdDatabaseModel.AdDatabaseEntities()) { return (from c in context.Sections where c.SectionsID == id select c.SectionName).ToString(); } }
public static string GetPositionSelectedIndex(int Position) { using (var context = new AdDatabaseModel.AdDatabaseEntities()) { return (from c in context.Positions where c.Position1 == Position select c.PositionID).ToString(); } }
public static string GetPosition( int selectedindex) { using (var context = new AdDatabaseModel.AdDatabaseEntities()) { return (from c in context.Positions where c.PositionID == selectedindex select c.Position1).ToString(); } }
protected void Payment() { //PaymentDue var context = new AdDatabaseModel.AdDatabaseEntities(); var advertiserPaymentDue = new AdDatabaseModel.AdvertiserPaymentDue { AdvertiserID = GetUserID(), PaymentDueID = Helpers.Utility.GetPaymentID(), AdID = GetTempAdID(), AdAmount = PaymentDue(), Date = DateTime.Now.Date, CurrencyCode = "USA", PaymentDue = PaymentDue() }; context.AddToAdvertiserPaymentDues(advertiserPaymentDue); context.SaveChanges(); }
private void TopBanner(string positionid, string sectionId) { string keyword; using (var context = new AdDatabaseModel.AdDatabaseEntities()) { var t = Utility.KeywordFiltering(positionid, sectionId,GetCurrentLCID()); var queryKeywordFilter = (from k in context.AdGenerals where k.Keyword == t select k).ToList(); keyword = queryKeywordFilter.Count == 0 ? Logic.GetDefaultTopKeyword(sectionId) : Utility.KeywordFiltering(positionid, sectionId, GetCurrentLCID()); } TopBannerRotator.KeywordFilter = keyword; }
protected double PaymentDue() { //Formual Prospective //Sections * Industry * Profession * Date //Current Forumla //Profession * date int y = GetTempAdID(); using (var context2 = new AdDatabaseModel.AdDatabaseEntities()) { var tempad = (from ad in context2.TempAds where ad.ID == y select ad).FirstOrDefault(); int numberofprofession = int.Parse(tempad.NumberofProfession.ToString(CultureInfo.InvariantCulture)); int numberofdays = (int)(tempad.StartDate - tempad.EndDate).TotalDays; return numberofprofession * numberofdays; } }
public static string GetNumberofProfession(int id) { using (var context = new AdDatabaseModel.AdDatabaseEntities()) { var result = from c in context.PendingAds where c.ID == id select c.NumberofProfession; var resultcode = result.FirstOrDefault(); return resultcode.ToString(); } }
public static void DeleteAd(int AdID) { var context = new AdDatabaseModel.AdDatabaseEntities(); context.DeleteCurrentAd(AdID); context.SaveChanges(); }
public static int GetNumberofProfessionFromCurrent(int id) { using (var context = new AdDatabaseModel.AdDatabaseEntities()) { var result = from c in context.PendingAds where c.ID == id select c.Profession; var resultQuery = result.FirstOrDefault(); if (resultQuery != null) { var resultcode = resultQuery.ToString(CultureInfo.InvariantCulture); return resultcode.Count(f => f == ','); } else { return 0; } } }
protected void InsertNewTempAd(Guid userID) { ////////////////////Currently; providing regular compaing:Type 1///////////////// //If sponsorship arise in the feature, then will need to implement other adType const int adTypeID = 1; _currentTempID = Helpers.Utility.GetTempAdID(); if (AsyncFileUpload1 != null) { var adPath = "Ads/" + User.Identity.Name + "/" + AsyncFileUpload1.FileName.ToString(CultureInfo.InvariantCulture); using (var context2 = new AdDatabaseModel.AdDatabaseEntities()) context2.AddTempAd(_currentTempID, SiteDropDownList.SelectedIndex, SectionDropDownList.SelectedIndex, Convert.ToInt32(Helpers.Utility.GetPosition(PositionDropDownList.SelectedIndex)), GetDestinationURL(), FormatDropDownList.SelectedIndex, adPath, AlternativeText(), GetKeywordString(), Helpers.Utility.GetImpression(SpecialityListBox1, SpecialityListBox2, SpecialityListBox3), GetCreativeWidth(FormatDropDownList.SelectedIndex), GetCreativeHeight(FormatDropDownList.SelectedIndex), GetStartDate(), GetEndDate(), userID, LanguageDropDownList.SelectedIndex, GenderDropDownList.SelectedIndex, AgeDropDownList.SelectedIndex, Convert.ToInt32(CountryDropDownList.SelectedValue), CountryDropDownList.SelectedItem.Text, Convert.ToInt32(RegionsDropDownList.SelectedValue), RegionsDropDownList.SelectedItem.Text, CitiesDropDownList.SelectedIndex, GetCityName(), Helpers.Utility.GetZipcode(Convert.ToInt32(CountryDropDownList.SelectedValue), Convert.ToInt32(RegionsDropDownList.SelectedValue), GetCityName(), ZipcodeTextBox.Text), IndustryDropDownList.SelectedIndex, Helpers.Utility.GetNumberOfProfession(SpecialityListBox1, SpecialityListBox2, SpecialityListBox3), Helpers.Utility.GetProfession( SpecialityListBox1, SpecialityListBox2, SpecialityListBox3), Convert.ToDateTime(DateTime.Now.ToString(CultureInfo.InvariantCulture)), NewCampaingTextBox.Text, adTypeID, Helpers.Utility.GetCountryCode(Convert.ToInt32(CountryDropDownList.SelectedValue)), Helpers.Utility.GetFlagPath(Convert.ToInt32(CountryDropDownList.SelectedValue)), Helpers.Utility.GetProfessionID(SpecialityListBox1, SpecialityListBox2, SpecialityListBox3)); } }
private static int GetAdID() { int adID; var context = new AdDatabaseModel.AdDatabaseEntities(); var max = context.AdAudiences.OrderByDescending(s => s.AdID).FirstOrDefault(); if (max == null) { adID = 0; } else { adID = max.AdID + 1; } return adID; }