public ActionResult Insert(string id = "") { var cate = new ChannelModel(); if (!string.IsNullOrEmpty(id)) { cate = ChannelDal.Get(id,EnumChannelQueryKey.Id); } ViewBag.cate = cate; return View(); }
public static void UpdateChannel(ChannelModel channel) { //var query = Query.EQ("_id", channel.Id); //var update = Update<ChannelModel>.Set(e => e.Description, channel.Description); //update.Set(u => u.Name, channel.Name); //update.Set(u => u.CateId, channel.CateId); //update.Set(u => u.Status, channel.Status); //update.Set(u => u.Image, channel.Image); //update.Set(u => u.CreateTime, channel.CreateTime); //update.Set(u => u.UpdateTime, DateTime.Now); //Collection.Update(query, update); }
public ActionResult Insert(string id, ChannelModel channel) { channel.UpdateTime = DateTime.Now; if (!string.IsNullOrEmpty(id)) { channel.Id = ObjectId.Parse(id); ChannelDal.UpdateChannel(channel); } else { channel.CreateTime = DateTime.Now; channel.Status = EnumChannelStatus.Normal; ChannelDal.AddChannel(channel); } return RedirectToRoute(Insert()); }
public static ChannelModel GetChannelIdByLink(string link) { var info = GetInfoByLink(link); if (info == new Tuple<string, string, string, string>("", "", "", "") || string.IsNullOrEmpty(info.Item2) || string.IsNullOrEmpty(info.Item3)) { return null; } var type = info.Item1; var channelLinkName = info.Item2; var title = info.Item3; var cateLinkName = info.Item4; ChannelModel channel = ChannelDal.Get(GetChannelInfoByLink(link, false).link, EnumChannelQueryKey.LinkName); if (channel == null) { //insert new channelid if (info.Item1.ToLower() != "events") { var channelInfo = GetChannelInfoByLink(link, false); ChannelModel newchannel = new ChannelModel() { CreateTime = DateTime.Now, UpdateTime = DateTime.Now, Name = channelInfo.title,// info.Item2, Description = channelInfo.descrtiption,// info.Item2, Image = channelInfo.image, LinkName = channelInfo.link, ParentId = null, ParentType = EnumChannelParent.Default, Status = EnumChannelStatus.Normal }; ChannelDal.AddChannel(newchannel); channel = ChannelDal.Get(info.Item2, EnumChannelQueryKey.Name); } else { var bigChannelInfo = GetChannelInfoByLink(link, true); //新建大频道.再建小频道 ChannelDal.AddChannel(new ChannelModel() { CreateTime = DateTime.Now, UpdateTime = DateTime.Now, Name = bigChannelInfo.title,//info.Item2, Description = bigChannelInfo.descrtiption,//info.Item2, Image = bigChannelInfo.image, LinkName = bigChannelInfo.link, ParentId = null, ParentType = EnumChannelParent.Events, Status = EnumChannelStatus.Normal }); var parentChanenl = ChannelDal.Get(bigChannelInfo.title, EnumChannelQueryKey.Name); var channelInfo = GetChannelInfoByLink(link, false); ChannelDal.AddChannel(new ChannelModel() { CreateTime = DateTime.Now, UpdateTime = DateTime.Now, Name = channelInfo.title,// info.Item3, Description = channelInfo.descrtiption,// info.Item3, Image = channelInfo.image, LinkName = channelInfo.link, ParentId = parentChanenl.Id.ToString(), ParentType = EnumChannelParent.Events, Status = EnumChannelStatus.Normal }); channel = ChannelDal.Get(info.Item3, EnumChannelQueryKey.Name); } } return channel; }
public static void AddChannel(ChannelModel channel) { Collection.Insert(channel.ToBsonDocument()); }