public void Update(Topic topic) { Topic _topic = dbCon.Topics.SingleOrDefault(x => x.Id == topic.Id); if (_topic != null) { _topic.ShortDesc = topic.ShortDesc; _topic.Content = topic.Content; _topic.CategoryId = topic.CategoryId; _topic.Title = topic.Title; _topic.Image = topic.Image; dbCon.SaveChanges(); } }
public ActionResult Create(Topic topic, int categoryId, HttpPostedFileBase upload) { if (upload != null) { string UploadPath = "~/Images/"; string fileName = String.Concat(DateTime.Now.ToString().GetHashCode(), upload.FileName); var imagePath = Path.Combine(Server.MapPath(UploadPath), fileName); var imageUrl = Path.Combine(UploadPath, fileName); upload.SaveAs(imagePath); topic.Image = fileName; } topic.CreatedDate = DateTime.Now; topic.CategoryId = categoryId; _topicService.Create(topic); return RedirectToAction("Index"); }
public ActionResult Edit(int categoryId, Topic model, HttpPostedFileBase upload) { if (upload != null) { string UploadPath = "~/Images/"; string fileName = String.Concat(DateTime.Now.ToString().GetHashCode(), upload.FileName); var imagePath = Path.Combine(Server.MapPath(UploadPath), fileName); var imageUrl = Path.Combine(UploadPath, fileName); upload.SaveAs(imagePath); model.Image = fileName; } _topicService.Update(model); return View(model); }
public void Update(Topic topic) { _topicRepository.Update(topic); }
public void Create(Topic topic) { _topicRepository.Create(topic); }
public void Create(Topic topic) { dbCon.Topics.Add(topic); dbCon.SaveChanges(); }