public ActionResult Homes(AddPropertyModel APModel) { /*using (TempProjectEntities DB = new TempProjectEntities()) * { * DB.ProductTables.Add(Product); * DB.SaveChanges(); * }*/ string FileName = Path.GetFileNameWithoutExtension(APModel.ProductImage.FileName); string Extension = Path.GetExtension(APModel.ProductImage.FileName); FileName = FileName + DateTime.Now.ToString("yymmssfff") + Extension; APModel.ImageUrl = FileName; FileName = Path.Combine(Server.MapPath("~/Content/LogoImages/"), FileName); APModel.ProductImage.SaveAs(FileName); AddPropertyManager obj = new AddPropertyManager(); int a = obj.Homes(APModel); if (a != 0) { ViewBag.Message = "Property Entered Succesfully"; } else { ViewBag.Message = "Property Not Entered Succesfully"; } return(View()); }
public int Homes(AddPropertyModel AP) { IDInsert(AP); string Query = "insert into dbo.Practice(UserID, City, [Location], PropertyType, Price, AreaInSqYd, Bedrooms, TVLounge, OutsideGarden, WestOpen, Corner, image) values ('" + UserID + "','" + AP.City + "','" + AP.Location + "','" + AP.PropertyType + "','" + AP.Price + "','" + AP.LandArea + "','" + AP.Bedrooms + "','" + AP.TVLounge + "','" + AP.OutsideGarden + "','" + AP.WestOpen + "','" + AP.Corner + "','" + AP.ImageUrl + "')"; SqlCommand cmd = new SqlCommand(Query, Con); Con.Open(); int a = cmd.ExecuteNonQuery(); Con.Close(); return(a); }
public void IDInsert(AddPropertyModel AP) { string Query = "select * from Users Where Username = '******' and Password = '******'"; Con.Open(); DataTable dt = new DataTable(); SqlDataAdapter DA = new SqlDataAdapter(Query, Con); DA.Fill(dt); Con.Close(); foreach (DataRow Row in dt.Rows) { UserID = Convert.ToInt32(Row["UserID"]); } }