public HttpResponseMessage Post() { HttpResponseMessage resultw = new HttpResponseMessage(); try { country objectCountry = new country(); using (SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["Connection"].ConnectionString)) { con.Open(); using (SqlCommand command = new SqlCommand("SELECT countryName FROM countries", con)) { using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { for (int i = 0; i < reader.FieldCount; i++) { objectCountry.listCountry.Add(Convert.ToString(reader.GetValue(i))); } } } } } string jsonCountries = JsonConvert.SerializeObject(objectCountry); if (objectCountry.listCountry.Any()) { resultw.StatusCode = HttpStatusCode.OK; resultw.Content = new StringContent(jsonCountries); return resultw; } else { resultw.StatusCode = HttpStatusCode.NotFound; resultw.Content = new StringContent(""); return resultw; } } catch (Exception ex) { resultw.StatusCode = HttpStatusCode.InternalServerError; resultw.Content = new StringContent(ex.ToString()); return resultw; } }
private void Fixupcountry(country previousValue) { if (previousValue != null && previousValue.addresses.Contains(this)) { previousValue.addresses.Remove(this); } if (country != null) { if (!country.addresses.Contains(this)) { country.addresses.Add(this); } if (country_id != country.id) { country_id = country.id; } } else if (!_settingFK) { country_id = null; } }
private string GetCountryInformation() { string strCountryInfo = String.Empty; //check if the executionSymbol is not blank //if (String.IsNullOrEmpty(executionSymbol)) //{ // //stop the processing // return quoteInfo; //} try { //create a StockQuote object country countryObject = new country(); //airport aiportObject = new airport(); //get the country information for the specified symbol strCountryInfo = countryObject.GetCountries(); //strCountryInfo= } catch (Exception ex) { //raise the error string errorMessage = String.Format("Error while trying to connect to the Web Service. {0}", ex.Message); throw new Exception(errorMessage); } //return the quote information return strCountryInfo; }
/// <summary> /// 修改 /// </summary> public void Updatecountry(country country) { ExecuteUpdate("Updatecountry", country); }
public CountrieTranslate(country country) { Country = country; //CountryName = Translate(country.Name); CountryName = country.Name; }
/// <summary> /// Prompting for a country table. /// </summary> private static void AddCountryPrompt() { country c = new country(); string input; // Name Console.Write("Name: "); input = Console.ReadLine(); if (input != string.Empty) { c.name = input; } else { throw new EmptyInputException(); } // Population Console.Write("Population: "); input = Console.ReadLine(); if (input != string.Empty) { if (int.TryParse(input, out int population)) { c.population = population; } else { throw new FormatException(); } } else { throw new EmptyInputException(); } // Capital Console.Write("Capital: "); input = Console.ReadLine(); if (input != string.Empty) { c.capital = input; } else { throw new EmptyInputException(); } // Continent Console.Write("Continent: "); input = Console.ReadLine(); if (input != string.Empty) { c.continent = input; } else { throw new EmptyInputException(); } // Area Console.Write("Area: "); input = Console.ReadLine(); if (input != string.Empty) { if (int.TryParse(input, out int area)) { c.area = area; } else { throw new FormatException(); } } else { throw new EmptyInputException(); } new CountryLogic().Insert(c); }
/// <summary> /// 新建 /// </summary> public void Addcountry(country country) { country.CountryId = new aers_sys_seedSqlMapDao().GetMaxID("CertificateAudit"); ExecuteInsert("Insertcountry", country); }
/// <inheritdoc/> public void AddCountry(country c) { this.db.country.Add(c); this.db.SaveChanges(); }
public person() { country = new country(); }
public string get(string city) { country c = new country(); return(c.getCountryCode(city)); }
private void cbCountry_SelectedIndexChanged(object sender, EventArgs e) { country c = (country)cbCountry.SelectedItem; filter.countryId = c.countryId; }
public void AddCountry(country country) { _countryRepository.Add(country); }
// // GET: /Admin/Country/Delete/5 public ActionResult Delete(int id) { country country = db.countries.Single(c => c.CountryID == id); return(View(country)); }
public async Task <ActionResult> Create_Biz(FormCollection collection, [Bind(Exclude = "logo")] BusinessInfo biz, HttpPostedFileBase logo) { try { if (!ModelState.IsValid) { return(View(biz)); } // status s = new status(); var userId = Session["Id"].ToString(); var u = db.Users.Find(userId); country c = db.country.Find(Convert.ToInt32(biz.Country)); var st = db.State.Find(Convert.ToInt32(collection["state"])); var cat = db.category.Find(Convert.ToInt32(biz.Category)); BusinessInfo b = new BusinessInfo(); b.UserID = userId; b.businessName = biz.businessName; b.Country = c.CountryName; b.State = st.StateName; b.City = collection["city"]; b.Email = biz.Email; b.Phone = biz.Phone; b.Category = cat.CatName; b.Website = biz.Website; b.Address = biz.Address; b.NotifyStatus = 0; b.regDate = DateTime.UtcNow; b.ApprovedStatus = "P"; b.VerifiedStatus = "NV"; b.Description = Server.HtmlEncode(sanitizer.Sanitize(collection["summary"], "", null)); b.Facebook = biz.Facebook; b.Twitter = biz.Twitter; b.LinkedIn = biz.LinkedIn; b.Google_Plus = biz.Google_Plus; b.Custom_Url = seo.generate_title(biz.businessName); b.isServiceBooster = (u.isClientBooster == true) ? "Yes" : "No"; if (collection["subCat1"] != null) { var sb1 = db.SubCategory1.Find(Convert.ToInt32(collection["subCat1"])); b.subCategory1 = sb1.SubCat1Name; if (collection["subCat2"] != null) { var sb2 = db.SubCategory2.Find(Convert.ToInt32(collection["subCat2"])); b.subCategory2 = sb2.SubCat2name; } } //if (collection["lat"] != "" && collection["long"] != "") //{ // string Long = collection["long"]; // string Lat = collection["lat"]; // string cordinate = string.Format("Point({0} {1})", Lat,Long); // b.mapLocation = DbGeography.FromText(cordinate, 4326); //} if (logo != null) { byte[] img; System.Drawing.Image image2validate = System.Drawing.Image.FromStream(logo.InputStream, true, true); decimal size = Math.Round(logo.ContentLength / (decimal)1024, 2); if (size <= 1000) { img = ImageRz.imageToByteArray(image2validate, image2validate.RawFormat, 111, 119); b.logo = img; } else { TempData["error"] = "Uploaded Image size exceed 1000kb(i.e.1MB)!"; return(View()); } } db.BusinessInfoes.Add(b); await db.SaveChangesAsync(); await e.bizRegistrationMail(u.Email, biz.Email, biz.Phone, biz.businessName, biz.Address, cat.CatName, u.FirstName); // TODO: Add insert logic here TempData["success"] = "Business registration was successfull!"; TempData["info"] = "We will Notify you upon approver, Thanks."; return(Redirect(Request.Url.ToString())); } catch (Exception ex) { TempData["error"] = ex.ToString(); return(View()); } }