public async Task <Suburb> UpdateAsync(Suburb suburb) { this.context.suburbs.Update(suburb); await SaveAllAsync(suburb); return(suburb); }
public async Task <IHttpActionResult> PostPostcode([FromBody] Postcode postcode) { if (!ModelState.IsValid) { ModelState.AddModelError("Message", "The postcode details are not valid!"); return(BadRequest(ModelState)); } try { db.Postcodes.Add(postcode); await db.SaveChangesAsync(); Postcode lastpc = await db.Postcodes.OrderByDescending(pc => pc.id).FirstAsync(); // add the dummy suburb so the app does not fail Suburb sub = new Suburb(); sub.postcodeId = lastpc.id; sub.name = "Miscellaneous"; await subctr.PostSuburb(sub); return(Ok <Postcode>(lastpc));; } catch (Exception) { ModelState.AddModelError("Message", "Error during saving your postcode!"); return(BadRequest(ModelState)); } }
public async Task <Suburb> CreateAsync(Suburb suburb) { await this.context.suburbs.AddAsync(suburb); await SaveAllAsync(suburb); return(suburb); }
public IHttpActionResult PutSuburb(int id, Suburb suburb) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != suburb.SuburbID) { return(BadRequest()); } db.Entry(suburb).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SuburbExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void AddPropertyDetails() { obj.ClickAddNewProperty(); // Populating the data from Excel ExcelLib.PopulateInCollection(Base.ExcelPath, "PropertyDetails"); PropertyName.SendKeys(ExcelLib.ReadData(2, "PropertyName")); SearchAddress.SendKeys(ExcelLib.ReadData(2, "SearchAddress")); Description.SendKeys(ExcelLib.ReadData(2, "Description")); Number.SendKeys(ExcelLib.ReadData(2, "Number")); Street.SendKeys(ExcelLib.ReadData(2, "Street")); Suburb.SendKeys(ExcelLib.ReadData(2, "Suburb")); City.SendKeys(ExcelLib.ReadData(2, "City")); PostCode.SendKeys(ExcelLib.ReadData(2, "PostCode")); Region.SendKeys(ExcelLib.ReadData(2, "Region")); YearBuilt.SendKeys(ExcelLib.ReadData(2, "YearBuilt")); TargetRent.SendKeys(ExcelLib.ReadData(2, "TargetRent")); LandArea.SendKeys(ExcelLib.ReadData(2, "LandArea")); FloorArea.SendKeys(ExcelLib.ReadData(2, "FloorArea")); BedRooms.SendKeys(ExcelLib.ReadData(2, "Bedrooms")); BathRooms.SendKeys(ExcelLib.ReadData(2, "Bathrooms")); CarPark.SendKeys(ExcelLib.ReadData(2, "Carparks")); owneroccupied = ExcelLib.ReadData(2, "Owner Occupied"); if (owneroccupied == "Yes") { OwnerOccupied.Click(); } Next.Click(); AddFinanceDetails(); }
public async Task <IActionResult> Edit(long id, [Bind("SuburbId,SuburbName,SuburbCode,CityId,CreatedBy,DateCreated,LastUpdatedBy,DateUpdated")] Suburb suburb) { if (id != suburb.SuburbId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(suburb); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SuburbExists(suburb.SuburbId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CityId"] = new SelectList(_context.City, "CityId", "CityName", suburb.CityId); return(PartialView(suburb)); }
public IHttpActionResult Details(List <String> suburbs) { System.Diagnostics.Debug.WriteLine("debug:"); System.Diagnostics.Debug.WriteLine(suburbs); if (suburbs != null) { //find suburbs List <SuburbCrime> SuburbCrimeList = new List <SuburbCrime>(); foreach (var i in suburbs) { Suburb theSuburb = db.Suburb.Find(i); CrimeRate theRate = db.CrimeRate.Find(i); if (theSuburb != null && theRate != null) { var newSub = new SuburbCrime(); newSub.suburbname = i; newSub.boundary = theSuburb.Boundary1 + theSuburb.Boundary2; newSub.crimeRate = theRate.Rate; SuburbCrimeList.Add(newSub); } } String json = JsonConvert.SerializeObject(SuburbCrimeList); //output Json type suburb details to front-end return(Json(json)); } else { return(Json("failed")); } //Suburb suburb = db.Suburb.Find(id); }
// GET: Suburb public ActionResult getSuburb(String id) { Suburb db = new Suburb(); var suburbList = db.postcodes_location.Where(x => x.state == id).Select(x => x.suburb).ToList(); return(Json(suburbList, JsonRequestBehavior.AllowGet)); }
private void SaveButton() { string validateMessage = ValidateData(); if (validateMessage == null) { try { Suburb suburb = new Suburb(SuburbName); DAL.InsertSuburb(suburb); new EventLogger().Log("Inserted Suburb in database"); } catch (MySqlException) { MessageBox.Show("Failed to save suburb", "Saving Failed", MessageBoxButtons.OK); } ResetDataEntry(); LoadSuburbList(); } else { System.Windows.Forms.MessageBox.Show(validateMessage, "Saving Failed", MessageBoxButtons.OK); } }
public void UpdateCustomer() { Customer customer = new Customer(); customer.IdCustomer = Convert.ToInt32(txtId.Text); customer.Name = txtName.Text; customer.PostalCode = txtPostal.Text; customer.Phone = txtPhone.Text; customer.Address = txtAddress.Text; customer.IdOccupation = Convert.ToInt32(cmbJobTitle.SelectedValue); customer.IdEducation = Convert.ToInt32(cmbEducation.SelectedValue); customer.IdSuburb = Convert.ToInt32(cmbSuburb.SelectedValue); { Occupation occupation = new Occupation(); occupation.Description = cmbJobTitle.Text; Education education = new Education(); education.Name = cmbEducation.Text; Suburb suburb = new Suburb(); suburb.Name = cmbSuburb.Text; customer.educ = education; customer.oc = occupation; customer.sub = suburb; } logic.UpdateCustomer(customer); }
public OperationResult <string> Suburb2Area([FromUri] string country, [FromUri] string city, [FromUri] string suburb) { var result = new OperationResult <string>(true); if (country.ToUpper().Equals("NZ") && city.ToUpper().Equals("AUCKLAND")) { //get surburb for auckland var suburbRec = Suburb.Find(suburb, city, country, _db); if (suburbRec != null) { result.Data = suburbRec.Area; } else { result.Succeeded = false; result.Message = "不能识别Suburb"; } } else { result.Data = city; } return(result); }
public bool Add(AddSuburb model) { bool status = false; Suburb suburb = datacontext.Suburbs.Where(w => w.Name == model.name && w.State.StateId == model.stateid).FirstOrDefault(); if (suburb == null) { suburb = new Suburb(); suburb.StateId = model.stateid; suburb.Name = model.name; suburb.NameURL = model.nameurl; DateTime dt; if (DateTime.TryParse(model.established, out dt)) { suburb.Established = (DateTime)dt; } else { suburb.Established = DateTime.MaxValue; } datacontext.Suburbs.Add(suburb); datacontext.SaveChanges(); status = true; } return(status); }
/// <summary> /// Converts <see cref="Suburb"/> to <see cref="SuburbDto"/> /// </summary> /// <param name="suburb"> /// The Suburb object /// </param> /// <returns> /// The Suburb DTO object /// </returns> public static SuburbDto ToSuburbDto(this Suburb suburb) { return(suburb == null ? null : new SuburbDto() { Id = suburb.Id, Name = suburb.Name, PostCode = suburb.PostCode }); }
public ActionResult DeleteConfirmed(int id) { Suburb suburb = db.Suburbs.Find(id); db.Suburbs.Remove(suburb); db.SaveChanges(); return(RedirectToAction("Index")); }
public void AddSuburb(Suburb suburb) { if (!_context.Suburbs.Any(s => s.Id == suburb.Id)) { // Only add if doesn't already exist. _context.Suburbs.Add(suburb); } }
public static SuburbDTO ToDTO(this Suburb ObjectToConvert) { return(new SuburbDTO() { ID = ObjectToConvert.ID, Name = ObjectToConvert.Name, PostalCode = ObjectToConvert.PostalCode }); }
public IActionResult Post([FromBody] Suburb suburb) { using (var scope = new TransactionScope()) { _Repo.Insert(suburb); scope.Complete(); return(CreatedAtAction(nameof(Get), new { id = suburb.Id }, suburb)); } }
public override int GetHashCode() { unchecked { var hash = 17; hash = hash * 23 + Suburb.GetHashCode(); hash = hash * 23 + Postcode.GetHashCode(); return(hash); } }
public List <dynamic> addSuburb([FromBody] Suburb suburb) { ReviveCommunicationsDBEntities3 db = new ReviveCommunicationsDBEntities3(); db.Configuration.ProxyCreationEnabled = false; db.Suburbs.Add(suburb); db.SaveChanges(); return(getAllSuburbs()); }
public ActionResult Edit([Bind(Include = "SuburbID,SuburbDescription")] Suburb suburb) { if (ModelState.IsValid) { db.Entry(suburb).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(suburb)); }
public IHttpActionResult GetSuburb(int id) { Suburb suburb = db.Suburbs.Find(id); if (suburb == null) { return(NotFound()); } return(Ok(suburb)); }
public ActionResult Edit([Bind(Include = "SuburbID,SuburbName,CityID")] Suburb suburb) { if (ModelState.IsValid) { db.Entry(suburb).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CityID = new SelectList(db.Cities, "CityID", "CityName", suburb.CityID); return(View(suburb)); }
public ActionResult Create([Bind(Include = "SuburbID,SuburbDescription")] Suburb suburb) { if (ModelState.IsValid) { db.Suburbs.Add(suburb); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(suburb)); }
public override bool Equals(object obj) { var other = obj as Address; if (other == null) { return(false); } return(Suburb.Equals(other.Suburb) && Postcode.Equals(other.Postcode)); }
public static int DeleteSuburb(Suburb suburb) { string storedProcedureName = "usp_deleteSuburb"; MySqlParameter[] parameterList = new MySqlParameter[] { new MySqlParameter("SuburbNameIn", suburb.SuburbName) }; return(ExecuteNonQuery(storedProcedureName, parameterList)); }
public bool Update(Suburb model) { bool status = false; if (datacontext.Suburbs.Where(w => w.SuburbId == model.SuburbId).Any()) { datacontext.Suburbs.Update(model); datacontext.SaveChanges(); status = true; } return(status); }
public async Task <int> Insert(Suburb suburb) { try { return(await _repo.Insert(suburb)); } catch (Exception ex) { _log.Error("SQL Error: {0}", ex.Message); return(0); } }
public IHttpActionResult PostSuburb(Suburb suburb) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Suburbs.Add(suburb); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = suburb.SuburbID }, suburb)); }
public static int RemovePreferredSuburb(Contractor contractor, Suburb suburb) { string storedProcedureName = "usp_removePreferredSuburb"; MySqlParameter[] parameterList = new MySqlParameter[] { new MySqlParameter("contractorIdIn", contractor.ContractorID), new MySqlParameter("suburbNameIn", suburb.SuburbName) }; return(ExecuteNonQuery(storedProcedureName, parameterList)); }
public ActionResult Create([Bind(Include = "SuburbID,SuburbName,CityID")] Suburb suburb) { if (ModelState.IsValid) { db.Suburbs.Add(suburb); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CityID = new SelectList(db.Cities, "CityID", "CityName", suburb.CityID); return(View(suburb)); }
public Contact(int contact_id, int entity_id, int contact_type_id, string free_text, string addr_line1, string addr_line2, int address_channel_id, int suburb_id, int country_id, int site_id, bool is_billing, bool is_non_billing, DateTime contact_date_added, DateTime contact_date_modified) { this.contact_id = contact_id; this.entity_id = entity_id; this.contact_type = new ContactType(contact_type_id); this.free_text = free_text; this.addr_line1 = addr_line1; this.addr_line2 = addr_line2; this.address_channel = address_channel_id == -1 ? null : new AddressChannel(address_channel_id); this.suburb = suburb_id == -1 ? null : new Suburb(suburb_id); this.country = country_id == -1 ? null : new IDandDescr(country_id); this.site = site_id == -1 ? null : new Site(site_id); this.is_billing = is_billing; this.is_non_billing = is_non_billing; this.contact_date_added = contact_date_added; this.contact_date_modified = contact_date_modified; }
public void InsertSuburb(Suburb entity) { context.Suburbs.Add(entity); }
public void UpdateSuburb(Suburb entity) { context.Entry(entity).State = EntityState.Modified; }