public ActionResult EditHotels2(HotelsCustomModel Hotels_OBJ, int ID, string Name, string Location, string Gov_License, string Standard, string Charges) { try { //Adding hotel information in database firts so we can get hotel id , which will use in hotel-image table //Hotels_OBJ.Hotels.ID = ID; //Hotels_OBJ.Hotels.Name = Name; //Hotels_OBJ.Hotels.Location = Location; //Hotels_OBJ.Hotels.Gov_License = Gov_License; //Hotels_OBJ.Hotels.Standard = Standard; //Hotels_OBJ.Hotels.Charges = Charges; int id = 1013; //Common_Mapping_model_obj.Update_hotel2(Hotels_OBJ); foreach (var file in Hotels_OBJ.Files) { if (file != null && file.ContentLength > 0) { //image name lay rai hn string fileName = Path.GetFileNameWithoutExtension(file.FileName); //image extension string Extension = Path.GetExtension(file.FileName); //unique name fileName = fileName + DateTime.Now.ToString("yymmssff") + Extension; //saving path to db Hotels_OBJ.Hotels.ImagePath = "/images/" + fileName; //creating path from computer path + file name fileName = Path.Combine(Server.MapPath("/images/"), fileName); //obj.userimageFile mai jo image a rai hai usko save kr do folder mai file.SaveAs(fileName); //storing hotel id into obj to use in hotel image table Hotels_OBJ.Hotels.ID = id; //Adding hotel images in database Common_Mapping_model_obj.Insert_hote_Images(Hotels_OBJ); TempData["hotel_Created"] = "Hotel Updated Successfully"; } } } catch (Exception e) { TempData["hotel_Not_Created"] = "There Is A Prabblem In Adding New Hotel" + e.Message; } return(View()); }
public int Update_hotel2(HotelsCustomModel model) { tbl_Hotels Hotel = model.Hotels; int id = Hotels_obj.Upadate2(Hotel); return(id); }
// HotelsCustomModel METHODS public int Insert_hotel(HotelsCustomModel model) { tbl_Hotels Hotel = model.Hotels; int id = Hotels_obj.Insert(Hotel); return(id); }
public void Update_hotel_Images(HotelsCustomModel model) { tbl_Hotel_images Hotelimages = new tbl_Hotel_images(); Hotelimages.ID = model.Hotels.ID; Hotelimages.ImagePath = model.Hotels.ImagePath; Hotel_ImagesDB_Obj.Upadate(Hotelimages); }
// HotelsCustomModel METHODS public int Insert_hote_Images(HotelsCustomModel model) { tbl_Hotel_images Hotelimages = new tbl_Hotel_images(); Hotelimages.Hotel_ID = model.Hotels.ID; Hotelimages.ImagePath = model.Hotels.ImagePath; int id = Hotel_ImagesDB_Obj.Insert(Hotelimages); return(id); }
public ActionResult CreateHotels(HotelsCustomModel Hotels_OBJ) { try { if (ModelState.IsValid) { if (Hotels_OBJ.UserImageFiles != null) { //image name lay rai hn string fileName = Path.GetFileNameWithoutExtension(Hotels_OBJ.UserImageFiles.FileName); //image extension string Extension = Path.GetExtension(Hotels_OBJ.UserImageFiles.FileName); //unique name fileName = fileName + DateTime.Now.ToString("yymmssff") + Extension; //saving path to db Hotels_OBJ.Hotels.ImagePath = "/images/" + fileName; //creating path from computer path + file name fileName = Path.Combine(Server.MapPath("/images/"), fileName); //obj.userimageFile mai jo image a rai hai usko save kr do folder mai Hotels_OBJ.UserImageFiles.SaveAs(fileName); } else if (Hotels_OBJ.Hotels.ImagePath == null) { Hotels_OBJ.Hotels.ImagePath = "/images/No_Image_Available.jpg"; } int id = Common_Mapping_model_obj.Insert_hotel(Hotels_OBJ); if (id > 0) { TempData["hotel_Created"] = "Hotel Added Successfully"; } } } catch (Exception e) { TempData["hotel_Not_Created"] = "There Is A Prabblem In Adding New Hotel" + e.Message; } return(RedirectToAction("CurrentHotels", "Admin", new { area = "Admin" })); }
public ActionResult EditHotels(HotelsCustomModel Hotels_OBJ) { try { if (ModelState.IsValid) { if (Hotels_OBJ.UserImageFiles != null) { //image name lay rai hn string fileName = Path.GetFileNameWithoutExtension(Hotels_OBJ.UserImageFiles.FileName); //image extension string Extension = Path.GetExtension(Hotels_OBJ.UserImageFiles.FileName); //unique name fileName = fileName + DateTime.Now.ToString("yymmssff") + Extension; //saving path to db Hotels_OBJ.Hotels.ImagePath = "/images/" + fileName; //creating path from computer path + file name fileName = Path.Combine(Server.MapPath("/images/"), fileName); //obj.userimageFile mai jo image a rai hai usko save kr do folder mai Hotels_OBJ.UserImageFiles.SaveAs(fileName); } if (Hotels_OBJ.Hotels.ImagePath == "/images/No_Image_Available.jpg") { Hotels_OBJ.Hotels.ImagePath = null; } Common_Mapping_model_obj.Update_hotel(Hotels_OBJ); TempData["Recored_Edited"] = "REOCORD EDITED SUCCESSFULLY"; } } catch (Exception e) { TempData["Recored_Edited"] = "REOCORD EDITED SUCCESSFULLY" + e.Message; } return(RedirectToAction("EditHotels", "Admin", new { area = "Admin" })); }
public void Update_hotel(HotelsCustomModel model) { tbl_Hotels Hotel = model.Hotels; Hotels_obj.Upadate(Hotel); }