public ActionResult Review(BDSExtNews model) { if (!ModelState.IsValid) { ViewBag.Success = false; ViewBag.Message = Resource.SaveFailed; return(Review(model)); } model.ApproveDate = DateTime.Now; model.ApproveUser = 1; model.KeySearch = model.Name.NormalizeD() + " " + (model.CatExtNews == 1 ? "Tin bất đông sản".NormalizeD() : "Chia sẽ kinh nghiệm".NormalizeD()) + " " + (String.IsNullOrEmpty(model.ShortDescription) ? "" : model.ShortDescription.NormalizeD()); model.KeyUrl = model.Name.UrlFrendly(); var path = string.Empty; var path1 = string.Empty; var NewPath = string.Empty; var fortmatName = string.Empty; var fileNameFull = model.UrlImage; var file = System.Web.HttpContext.Current.Request.Files["UrlImageFile"]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); string newFileNmae = Path.GetFileNameWithoutExtension(fileName); fortmatName = Path.GetExtension(fileName); NewPath = newFileNmae.Replace(newFileNmae, (DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString()).ToString()); fileNameFull = DateTime.Now.Day + "" + DateTime.Now.Month + "_" + NewPath + fortmatName; if (Server.MapPath("~/UploadImg/").Contains(ConfigurationManager.AppSettings["HostAdmin"])) { path = Server.MapPath("~/UploadImg/").Replace(ConfigurationManager.AppSettings["HostAdmin"], ConfigurationManager.AppSettings["HostWeb"]) + DateTime.Now.Day + DateTime.Now.Month + "/"; } else { path = Server.MapPath("~/UploadImg/").Replace("Davisoft_BDSProject.Web", "WebBDS_Project") + DateTime.Now.Day + DateTime.Now.Month + "/"; } if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path1 = Path.Combine(path, fileNameFull); file.SaveAs(path1); } model.UrlImage = fileNameFull; model.ApproveDate = DateTime.Now; model.ApproveUser = CurrentUser.Identity.ID; _service.UpdateItem(model); ViewBag.Success = true; ViewBag.Message = Resource.SaveSuccessful; return(RedirectToAction("Index")); }
public ActionResult Review(int id) { BDSExtNews model = _service.GetItem(id); return(View(model)); }