// GET: Property/Edit/5 public ActionResult Edit(int id) { newAddProppertyViewModel mod = DataController.getProperty(id); // return Edit(id, mod); return(View(mod)); }
public static newAddProppertyViewModel getPropertyAt(string id) { SqlConnection con = new SqlConnection(); string path = ConfigurationManager.ConnectionStrings[db].ConnectionString; con.ConnectionString = path; newAddProppertyViewModel model = new newAddProppertyViewModel(); DataTable PropertyTable = new DataTable(); try { SqlDataAdapter adpProperties = new SqlDataAdapter("SELECT * from Property Where PropertyID = '" + id + "'", con); adpProperties.Fill(PropertyTable); } catch (DataException e) { throw e; } foreach (DataRow row in PropertyTable.Rows) { model.Address = row.ItemArray[1].ToString(); model.OpeningBid = Convert.ToDouble(row.ItemArray[2]); model.Description = row.ItemArray[3].ToString(); model.Documents = row.ItemArray[4].ToString(); model.Location = row.ItemArray[5].ToString(); } return(model); }
public static newAddProppertyViewModel getProperty(int id) { SqlConnection con = new SqlConnection(); string path = ConfigurationManager.ConnectionStrings[db].ConnectionString; con.ConnectionString = path; DataTable propertyId = new DataTable(); newAddProppertyViewModel model = new newAddProppertyViewModel(); try { SqlDataAdapter adpAuctions = new SqlDataAdapter("SELECT * from Property where PropertyID = '" + id + "'", con); adpAuctions.Fill(propertyId); } catch (DataException e) { throw e; } foreach (DataRow row in propertyId.Rows) { model.PropertyID = Convert.ToInt32(row.ItemArray[0]); model.Address = row.ItemArray[1].ToString(); model.OpeningBid = Convert.ToDouble(row.ItemArray[2]); model.Reserve = Convert.ToDouble(row.ItemArray[3]); model.Description = row.ItemArray[4].ToString(); model.Documents = row.ItemArray[5].ToString(); model.Location = row.ItemArray[6].ToString(); } return(model); }
public ActionResult Create(newAddProppertyViewModel model) { try { // TODO: Add insert logic here DataController.InsertProperty2(model); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Delete(int id, newAddProppertyViewModel model) { try { // TODO: Add delete logic here DataController.deleteProperty(id); return(RedirectToAction("Index")); //return View(); } catch (Exception e) { throw e; // return View(); } }
public ActionResult Edit(int id, newAddProppertyViewModel mod) { try { // TODO: Add update logic here DataController.editProperty(id, mod); return(RedirectToAction("Index")); } catch (Exception e) { throw e; } }
public static void InsertProperty2(newAddProppertyViewModel model) { SqlConnection con = new SqlConnection(); string path = ConfigurationManager.ConnectionStrings[db].ConnectionString; con.ConnectionString = path; try { SqlCommand Cmd = new SqlCommand("Insert Into Property (Address, OpeningBid, Reserve, Description, Documents, Location) Values('" + model.Address + "','" + model.OpeningBid + "','" + model.Reserve + "','" + model.Description + "','" + model.Documents + "','" + model.Location + "')", con); con.Open(); int RowsAffected = Cmd.ExecuteNonQuery(); // close connection when done con.Close(); } catch (DataException e) { throw e; } }
public static void editProperty(int id, newAddProppertyViewModel model) { SqlConnection con = new SqlConnection(); string path = ConfigurationManager.ConnectionStrings[db].ConnectionString; con.ConnectionString = path; try { SqlCommand Cmd = new SqlCommand("UPDATE Property SET Address = '" + model.Address + "', OpeningBid = " + model.OpeningBid + ", Description = '" + model.Description + "',Reserve='" + model.Reserve + "' ,Documents = '" + model.Documents + "', Location = '" + model.Location + "' WHERE PropertyID = '" + id + "'", con); con.Open(); int RowsAffected = Cmd.ExecuteNonQuery(); // close connection when done con.Close(); } catch (Exception e) { throw e; } }