public ActionResult Create(TopicObject topic) { try { // TODO: Add insert logic here var user = (UserObject)Session["user"]; //string groupId = TempData["GroupId"].ToString(); topic.Id = Guid.NewGuid().ToString(); topic.CreateDate = DateTime.Now; topic.LastModified = DateTime.Now; topic.NumberOfView = 0; topic.NumberOfComment = 0; topic.CreateBy = user; //topic.GroupId = groupId; topicService.Save(topic); var group = groupService.Load(topic.GroupId); group.ListTopic.Add(topic); groupService.Save(group); return RedirectToAction("Detail", "Group", new { id = topic.GroupId }); } catch { return View(); } }
protected bool CheckViewTopic(TopicObject topicObject) { IGroupService groupService = MvcUnityContainer.Container.Resolve(typeof(IGroupService), "") as IGroupService; var groupObject = groupService.Load(topicObject.GroupId); return CheckViewGroup(groupObject); }
public void Save(TopicObject topic) { session.Store(topic); session.SaveChanges(); }