public ActionResult Update(int id, enAdvertisement enAdvertisement_) { var objENAdvertisement = new enAdvertisement() { ID = id }; var objBLAdvertisement = new blAdvertisement(objENAdvertisement); List <enAdvertisement> listOfAdvertisements = new List <enAdvertisement>(); if (enAdvertisement_.AdvertisementImage != null) { enAdvertisement_.Image_Name = Path.GetFileName(enAdvertisement_.AdvertisementImage.FileName); enAdvertisement_.Image_Name = Helper.GetRandomAlphaNumericSMSToken() + "-" + enAdvertisement_.Image_Name; try { string extension = Path.GetExtension(enAdvertisement_.AdvertisementImage.FileName); var path = Path.Combine(Server.MapPath(Helper.AdvertisementImagePath()) + enAdvertisement_.Image_Name); bool exist = Directory.Exists(Server.MapPath(Helper.AdvertisementImagePath())); if (!exist) { Directory.CreateDirectory(Server.MapPath(Helper.AdvertisementImagePath())); } enAdvertisement_.AdvertisementImage.SaveAs(path); } catch (Exception ex) { return(RedirectToAction("error", "misc")); } try { objBLAdvertisement.Read(); } catch { RedirectToAction("error", "misc"); } enAdvertisement_.InsertedOn = objENAdvertisement.InsertedOn; objBLAdvertisement = new blAdvertisement(enAdvertisement_); try { objBLAdvertisement.Update(); } catch { RedirectToAction("error", "misc"); } } else { return(RedirectToAction("error", "misc")); } return(RedirectToAction("List")); }
public ActionResult Update(int id) { var objENAdvertisement = new enAdvertisement() { ID = id }; var objBLAdvertisement = new blAdvertisement(objENAdvertisement); List <enAdvertisement> listOfAdvertisements = new List <enAdvertisement>(); try { objBLAdvertisement.Read(); } catch { RedirectToAction("error", "misc"); } objENAdvertisement.Date_To = objENAdvertisement.Date_To.Date; return(View("index", objENAdvertisement)); }