public ActionResult UpdateTour(FormCollection fc) { if (fc["Post_id"].Trim() != null && fc["Post_id"].Trim() != "0") { Models.Tour TourOld = new Tour().GetByTourID(Convert.ToInt32(fc["Post_id"].Trim())); TourOld.Tour_Name = fc["Post_Tile"].Trim(); TourOld.Tour_Content = fc["editor"].Trim(); TourOld.Tour_OrganizationalUnit = fc["Tour_OrganizationalUnit"].Trim(); string Description = ""; if (Funtions.StripHTML(fc["editor"].Trim()).Length > 200) { Description = Funtions.StripHTML(fc["editor"].Trim()); } else { Description = Funtions.StripHTML(fc["editor"].Trim()); } TourOld.Tour_Description = Description; TourOld.Tour_Topic = fc.ToString("tour_Topic"); TourOld.Tour_Location = fc.ToInt("Tour_Location"); TourOld.Tour_Price = fc.ToInt("Tour_Price"); TourOld.Tour_DepartureDate = Funtions.ddMMyyyy(fc["Tour_DepartureDate"].Trim()); TourOld.Tour_TimeZone = Convert.ToInt32(fc["Tour_TimeZone"].Trim()); TourOld.Tour_Itinerary = fc["editor_Tour_Itinerary"].Trim(); TourOld.Tour_Schedule = fc["editor_Tour_Schedule"].Trim(); TourOld.Tour_Rules = fc["editor_Tour_Rules"].Trim(); TourOld.Tour_ListImage = fc["List_Images_Combo"].Trim(); TourOld.Tour_Image = fc["_thumbnail_id"].Trim(); TourOld.Product_ID = 1; TourOld.UserCreate = Convert.ToInt32(Session["User_ID"]); TourOld.Tour_StarRate = fc.ToDouble("Star_Rating"); TourOld.Tour_Qty = fc.ToInt("Tour_Qty"); TourOld.Tour_Score = fc.ToFloat("Tour_Score"); TourOld.Tour_Price = fc.ToInt("Tour_Price"); TourOld.Tour_PriceSale = fc.ToInt("Tour_PriceSale"); TourOld.Hotel_ID = fc.ToInt("Hotel_ID"); TourOld.Update(); TempData["MessagePost"] = "Cập nhật Combo thành công"; return(RedirectToAction("EditTour", "Manager", new { id = TourOld.Tour_ID })); } else { Models.Tour TourOld = new Tour(); TourOld.Tour_Name = fc["Post_Tile"].Trim(); TourOld.Tour_Content = fc["editor"].Trim(); TourOld.Tour_OrganizationalUnit = fc["Tour_OrganizationalUnit"].Trim(); string Description = ""; if (Funtions.StripHTML(fc["editor"].Trim()).Length > 200) { Description = Funtions.StripHTML(fc["editor"].Trim()); } else { Description = Funtions.StripHTML(fc["editor"].Trim()); } TourOld.Tour_Description = Description; TourOld.Tour_Topic = fc.ToString("tour_Topic"); TourOld.Tour_Location = fc.ToInt("Tour_Location"); TourOld.Hotel_ID = fc.ToInt("Hotel_ID"); TourOld.Tour_DepartureDate = Funtions.ddMMyyyy(fc["Tour_DepartureDate"].Trim()); TourOld.Tour_TimeZone = fc.ToInt("Tour_TimeZone"); TourOld.Tour_Itinerary = fc["editor_Tour_Itinerary"].Trim(); TourOld.Tour_Schedule = fc["editor_Tour_Schedule"].Trim(); TourOld.Tour_Rules = fc["editor_Tour_Rules"].Trim(); TourOld.Tour_ListImage = fc["List_Images_Combo"].Trim(); TourOld.Tour_Image = fc["_thumbnail_id"].Trim(); TourOld.Product_ID = 1; TourOld.UserCreate = Convert.ToInt32(Session["User_ID"]); TourOld.CreateDate = DateTime.Now; TourOld.Tour_StarRate = fc.ToDouble("Star_Rating"); TourOld.Tour_Qty = fc.ToInt("Tour_Qty"); TourOld.Tour_Score = fc.ToFloat("Tour_Score"); TourOld.Tour_Price = fc.ToInt("Tour_Price"); TourOld.Tour_PriceSale = fc.ToInt("Tour_PriceSale"); int TourID = TourOld.Insert(); TempData["MessagePost"] = "Thêm mới Combo thành công"; return(RedirectToAction("EditTour", "Manager", new { id = TourID })); } }
public ActionResult UpdatePost(FormCollection fc) { if (fc["Post_id"].Trim() != null && fc["Post_id"].Trim() != "0") { Models.Post postOld = new Post().GetByID(Convert.ToInt32(fc["Post_id"].Trim())); postOld.Post_Title = fc["Post_Tile"].Trim(); postOld.Post_Type = Convert.ToInt32(fc["Post_Type"].Trim()); //string Description = ""; //if (Funtions.StripHTML(fc["editor"].Trim()).Length > 200) //{ // Description = Funtions.StripHTML(fc["editor"].Trim()).Substring(0, 200); //} //else { Description = Funtions.StripHTML(fc["editor"].Trim()); } postOld.Post_Description = fc["editor_Description"].Trim();; postOld.Post_Content = fc["editor"].Trim(); postOld.Post_UpdateDate = DateTime.Now; postOld.Post_Images = fc["_thumbnail_id"].Trim(); postOld.Post_CategoryID = (fc["post_category"] + "").Trim(); postOld.Post_Location = Convert.ToInt32(fc["tour_Location"].Trim()); postOld.Post_Slug = Funtions.ConvertTitleToURL(fc["Post_Tile"].Trim()); postOld.Post_tag = fc["Post_tag"].Trim(); postOld.Post_UserID = Convert.ToInt32(Session["User_ID"]); postOld.Update(); TempData["MessagePost"] = "Cập nhật bài viết thành công"; return(RedirectToAction("EditPost", "Manager", new { id = postOld.Post_id })); } else { Models.Post postNew = new Post(); postNew.Post_Title = fc["Post_Tile"].Trim(); postNew.Post_Type = Convert.ToInt32(fc["Post_Type"].Trim()); string Description = ""; if (Funtions.StripHTML(fc["editor"].Trim()).Length > 200) { Description = Funtions.StripHTML(fc["editor"].Trim()).Substring(0, 200); } else { Description = Funtions.StripHTML(fc["editor"].Trim()); } postNew.Post_Description = Description; postNew.Post_Content = fc["editor"].Trim(); postNew.Post_CreateDate = DateTime.Now; postNew.Post_UpdateDate = DateTime.Now; postNew.Post_Images = fc["_thumbnail_id"].Trim(); postNew.Post_CategoryID = (fc["post_category"] + "").Trim(); postNew.Post_Slug = Funtions.ConvertTitleToURL(fc["Post_Tile"].Trim()); postNew.Post_tag = fc["Post_tag"].Trim(); postNew.Post_UserID = Convert.ToInt32(Session["User_ID"]); int idnew = postNew.Insert(); if (idnew > 0) { TempData["MessagePost"] = "Đăng bài viết thành công"; return(RedirectToAction("EditPost", "Manager", new { id = idnew })); } else { TempData["MessagePost"] = "Có lỗi xảy ra, vui lòng thử lại"; return(RedirectToAction("AddPost", "Manager", new { id = 0 })); } } }