コード例 #1
0
ファイル: TopicRepository.cs プロジェクト: darkbuivn/blog
 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();
     }
 }
コード例 #2
0
ファイル: TopicController.cs プロジェクト: darkbuivn/blog
 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");
 }
コード例 #3
0
ファイル: TopicController.cs プロジェクト: darkbuivn/blog
 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);
 }
コード例 #4
0
ファイル: TopicService.cs プロジェクト: darkbuivn/blog
 public void Update(Topic topic)
 {
     _topicRepository.Update(topic);
 }
コード例 #5
0
ファイル: TopicService.cs プロジェクト: darkbuivn/blog
 public void Create(Topic topic)
 {
     _topicRepository.Create(topic);
 }
コード例 #6
0
ファイル: TopicRepository.cs プロジェクト: darkbuivn/blog
 public void Create(Topic topic)
 {
     dbCon.Topics.Add(topic);
     dbCon.SaveChanges();
 }