public ActionResult UpdateWhatIDoAdd(HttpPostedFileBase Image, bool? chkPublish, WhatIDoTable whatIDoTable) { var seoMake = Seo.Translate(whatIDoTable.WhatIDoTitle); string filePath = whatIDoTable.WhatIDoImage; int publishId = whatIDoTable.PublishId; if (Image != null) { filePath = Path.GetFileName(Image.FileName); filePath = seoMake + ".jpg"; var uploadPath = Path.Combine(Server.MapPath("~/Content/Images/"), filePath); Image.SaveAs(uploadPath); } if (chkPublish == true) { publishId = 1; } _modelWhatIDo.UpdateWhatIDoData(whatIDoTable.WhatIDoTitle, whatIDoTable.WhatIDoContent, whatIDoTable.WhatIDoTags, DateTime.Now, seoMake, publishId, filePath, whatIDoTable.WhatIDoID); return RedirectToAction("Index", "AdmWhatIDo"); }
public void UpdateWhatIDoData(string whatIDoTitle, string whatIDoContent, string whatIDoTags, DateTime dateTime, string seoTitle, int publishId, string image, int id) { WhatIDoTable updateWhatIDoTable = _whatIDoContext.WhatIDos.First(uId => uId.WhatIDoID == id); updateWhatIDoTable.WhatIDoTitle = whatIDoTitle; updateWhatIDoTable.WhatIDoContent = whatIDoContent; updateWhatIDoTable.WhatIDoTags = whatIDoTags; updateWhatIDoTable.Date = dateTime; updateWhatIDoTable.SeoTitle = seoTitle; updateWhatIDoTable.PublishId = publishId; updateWhatIDoTable.WhatIDoImage = image; _whatIDoContext.SaveChanges(); }
public ActionResult WhatIDoAdd(HttpPostedFileBase Image, bool chkPublish, WhatIDoTable whatIDoTable) { var seoMake = Seo.Translate(whatIDoTable.WhatIDoTitle); string filePath = "content-icon.png"; int publishId = 0; if (Image != null) { filePath = Path.GetFileName(Image.FileName); filePath = seoMake + ".jpg"; var uploadPath = Path.Combine(Server.MapPath("~/Content/Images/"), filePath); Image.SaveAs(uploadPath); } if (chkPublish == true) { publishId = 1; } _modelWhatIDo.AddArticleData(whatIDoTable.WhatIDoTitle, whatIDoTable.WhatIDoContent, whatIDoTable.WhatIDoTags, DateTime.Now, seoMake, publishId, filePath); return(RedirectToAction("Index", "AdmWhatIDo")); }
public ModelWhatIDo() { _whatIDoContext = new MyWebContext(); _whatIDoTable = new WhatIDoTable(); }