public ActionResult Create(CTBusinessLayer.PhotoGallery collection) { if (ModelState.IsValid) { dbset.AddPhotoDetailsToDB(collection); return(RedirectToAction("Index")); } return(View()); }
// // GET: /CrystalManagerPhotos/Edit/5 public ActionResult Edit(int id) { CTBusinessLayer.PhotoGallery ctitem = dbset.PhotoGallerys.Single(emp => emp.photoId == id); if (ctitem == null) { return(HttpNotFound()); } return(View(ctitem)); }
public ActionResult Edit(CTBusinessLayer.PhotoGallery collection) { if (ModelState.IsValid) { var num = collection.photoId; dbset.SaveChangesPhotoDetailsToDB(collection); return(RedirectToAction("Index")); } return(View(collection)); }
public void SaveChangesPhotoDetailsToDB(PhotoGallery collection) { using (SqlConnection con = new SqlConnection(connectionString)) { SqlCommand cmd = new SqlCommand("spSaveChangesPhotoDetails", con); cmd.CommandType = CommandType.StoredProcedure; SqlParameter paramsellerAddress = new SqlParameter(); paramsellerAddress.ParameterName = "@photoAltName"; paramsellerAddress.Value = collection.photoAltName; //cmd.Parameters.Add(paramsellerAddress); cmd.Parameters.AddWithValue("@photoAltName", collection.photoAltName); SqlParameter paramsellerExpiryDate = new SqlParameter(); paramsellerExpiryDate.ParameterName = "@photoDescription"; paramsellerExpiryDate.Value = collection.photoDescription; //cmd.Parameters.Add(paramsellerExpiryDate); cmd.Parameters.AddWithValue("@photoDescription", collection.photoDescription); SqlParameter paramsellerName = new SqlParameter(); paramsellerName.ParameterName = "@photoLink"; paramsellerName.Value = collection.photoLink; //cmd.Parameters.Add(paramsellerName); cmd.Parameters.AddWithValue("@photoLink", collection.photoLink); SqlParameter paramsellerId = new SqlParameter(); paramsellerId.ParameterName = "@photoId"; paramsellerId.Value = collection.photoId; //cmd.Parameters.Add(paramsellerId); cmd.Parameters.AddWithValue("@photoId", collection.photoId); SqlParameter paramsellerWebsite = new SqlParameter(); paramsellerWebsite.ParameterName = "@photoName"; paramsellerWebsite.Value = collection.photoName; //cmd.Parameters.Add(paramsellerWebsite); cmd.Parameters.AddWithValue("@photoName", collection.photoName); con.Open(); cmd.ExecuteNonQuery(); } }