public async Task <IActionResult> Edit(string id, Properties properties) { if (id != properties.Address) { return(NotFound()); } if (ModelState.IsValid) { try { context.Update(properties); await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PropertiesExists(properties.Address)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Details))); } return(View(properties)); }
// GET: Properties /// <summary> /// Get to bring service data /// </summary> /// <returns></returns> public async Task <IActionResult> Index() { var respuesta = await CallToConsumeWebService().ConfigureAwait(false); List <Properties> datos = new List <Properties>(); foreach (var item in respuesta.properties) { string test = item.financial?.listPrice; string test2 = item.lease?.leaseSummary?.monthlyRent; double? result = (Convert.ToDouble(test2) * 12) / Convert.ToDouble(test); Properties tabla = new Properties { Address = item.address?.address1, Gross_Yield = result?.ToString(), Year_Built = item.physical?.yearBuilt, List_Price = test?.ToString(), Monthly_Rent = test2 != null?test2.ToString() : null }; datos.Add(tabla); } return(View(datos)); }
public async Task <IActionResult> Create(Properties properties) { var exist = context.Properties.FirstOrDefault(x => x.Address == properties.Address); if (exist == null) { if (ModelState.IsValid) { context.Add(properties); await context.SaveChangesAsync(); return(RedirectToAction(nameof(Details))); } } return(View(properties)); }