public ActionResult AddTourism(string id) { ViewBag.subList = new SelectList(_subcatTourism.GetAll(), "pkid", "SubCategory_Name"); ViewBag.cityList = new SelectList(_city.GetAll().Where(x => x.StateID == 1646).ToList(), "ID", "Name"); if (!String.IsNullOrWhiteSpace(id)) { int _id = Convert.ToInt32(id); tbl_TourismMaster model = _tourim.Get(_id); tbl_TourismMasterss abc = new tbl_TourismMasterss(); abc.pkid = model.pkid; abc.city_fkid = model.city_fkid; abc.Sub_fkid = model.Sub_fkid; abc.Name = model.Name; abc.AddedDate = model.AddedDate; abc.Description = model.Description; abc.Longitude = model.Longitude; abc.Lotitude = model.Lotitude; abc.openingTime = model.openingTime; abc.ClosingTime = model.ClosingTime; abc.Lid = model.Lid; abc.Address = model.Address; abc.ContactNumber = model.ContactNumber; abc.InchargeName = model.InchargeName; return(View(abc)); } return(View()); }
public ActionResult DeleteTourism(int id) { try { WebFunction web = new WebFunction(); tbl_TourismMaster abc = _tourim.Get(id); List <tbl_MultipleFileUpload> file = _mfile.GetAll().Where(x => x.SubMaster_fkid == abc.pkid).ToList(); foreach (var item in file) { web.DeleteImage(item.filepath); _mfile.Remove(item, true); } _tourim.Remove(id, true); return(Json("success", JsonRequestBehavior.AllowGet)); } catch { return(Json("failed", JsonRequestBehavior.AllowGet)); } }
public ActionResult AddTourism(tbl_TourismMasterss model, HttpPostedFileBase[] files) { ViewBag.subList = new SelectList(_subcatTourism.GetAll(), "pkid", "SubCategory_Name"); ViewBag.cityList = new SelectList(_city.GetAll().Where(x => x.StateID == 1646).ToList(), "ID", "Name"); try { if (model.pkid == 0) { tbl_TourismMaster abc = new tbl_TourismMaster(); abc.city_fkid = model.city_fkid; abc.Sub_fkid = model.Sub_fkid; abc.Name = model.Name; abc.AddedDate = model.AddedDate; abc.Description = model.Description; abc.Longitude = model.Longitude; abc.openingTime = model.openingTime; abc.ClosingTime = model.ClosingTime; abc.Lid = model.Lid; abc.Lotitude = model.Lotitude; abc.Address = model.Address; abc.ContactNumber = model.ContactNumber; abc.InchargeName = model.InchargeName; abc.LastModifiedDate = DateTime.Now; _tourim.Add(abc); int maxid = _tourim.GetAll().Max(x => x.pkid); if (files != null) { foreach (HttpPostedFileBase file in files) { //Checking file is available to save. if (file != null) { tbl_MultipleFileUpload fob = new tbl_MultipleFileUpload(); WebFunction web = new WebFunction(); fob.Master_fkid = 3; fob.SubMaster_fkid = maxid; fob.Lastmodifieddatetime = DateTime.Now; fob.filepath = web.Storefile(file, 3); _mfile.Add(fob); } } } } else { int _id = Convert.ToInt32(model.pkid); tbl_TourismMaster abc = _tourim.Get(_id); abc.city_fkid = model.city_fkid; abc.Sub_fkid = model.Sub_fkid; abc.Name = model.Name; abc.AddedDate = model.AddedDate; abc.Description = model.Description; abc.Longitude = model.Longitude; abc.Lotitude = model.Lotitude; abc.openingTime = model.openingTime; abc.ClosingTime = model.ClosingTime; abc.Lid = model.Lid; abc.Address = model.Address; abc.ContactNumber = model.ContactNumber; abc.InchargeName = model.InchargeName; abc.LastModifiedDate = DateTime.Now; _tourim.Update(abc); foreach (HttpPostedFileBase file in files) { //Checking file is available to save. if (file != null) { tbl_MultipleFileUpload fob = new tbl_MultipleFileUpload(); WebFunction web = new WebFunction(); fob.Master_fkid = 3; fob.SubMaster_fkid = model.pkid; fob.Lastmodifieddatetime = DateTime.Now; fob.filepath = web.Storefile(file, 3); _mfile.Add(fob); } } } return(RedirectToAction("AddTourism", "Administration")); } catch (Exception e) { Commonfunction.LogError(e, Server.MapPath("~/Log.txt")); ViewBag.Exception = e.Message; return(View()); } }