Example #1
0
        public bool AddChannel(Channel_Model model, string user, ref string msg)
        {
            using (var db = new PermaisuriCMSEntities())
            {
                var isExist = db.Channel.FirstOrDefault(c => c.ChannelName == model.ChannelName);
                msg = string.Empty;
                if (isExist != null)
                {
                    msg = "This item does exist";
                    return(false);
                }

                var newChannel = new Channel
                {
                    ChannelName = model.ChannelName,
                    ShortName   = model.ShortName,
                    Modifier    = user,
                    Modify_Date = DateTime.Now,
                    API         = model.API,
                    Export2CSV  = model.Export2CSV
                };
                db.Channel.Add(newChannel);
                return(db.SaveChanges() > 0);
            }
        }
        /// <summary>
        /// Change1:新增重复插入判断(ChannleName).2014年2月20日
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ActionResult AddChannel(Channel_Model model)
        {
            try
            {
                if (model == null)
                {
                    return(Json(new NBCMSResultJson
                    {
                        Status = StatusType.Error,
                        Data = "Request is illegal!"
                    }));
                }
                var cookis      = Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]];
                var serializer  = new JavaScriptSerializer();
                var decCookies  = CryptTools.Decrypt(cookis);
                var curUserInfo = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model;
                var cis         = new ChannelInfoServices();

                //if(curUserInfo==null)
                //{
                //    return Json(new NBCMSResultJson
                //    {
                //        Status = StatusType.Exception,
                //        Data = "aa"
                //    });
                //}

                var msg = string.Empty;
                if (cis.AddChannel(model, curUserInfo.User_Account, ref msg))
                {
                    return(Json(new NBCMSResultJson
                    {
                        Status = StatusType.OK,
                        Data = "Successfully add Channel"
                    }));
                }
                else
                {
                    return(Json(new NBCMSResultJson
                    {
                        Status = StatusType.Error,
                        Data = msg == string.Empty ? "faile to add new Channel" : msg
                    }));
                }
            }
            catch (Exception ex)
            {
                NBCMSLoggerManager.Fatal(ex.Message);
                NBCMSLoggerManager.Fatal(ex.StackTrace);
                NBCMSLoggerManager.Error("");
                return(Json(new NBCMSResultJson
                {
                    Status = StatusType.Exception,
                    Data = ex.Message
                }));
            }
        }
        public ActionResult EditChannel(Channel_Model model)
        {
            try
            {
                if (model == null)
                {
                    return(Json(new NBCMSResultJson
                    {
                        Status = StatusType.Error,
                        Data = "Request is illegal!"
                    }));
                }

                User_Profile_Model  curUserInfo = new CommonController().GetCurrentUserbyCookie(Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]);
                ChannelInfoServices cis         = new ChannelInfoServices();

                string msg = string.Empty;
                if (cis.EditChannel(model, curUserInfo.User_Account, ref msg))
                {
                    return(Json(new NBCMSResultJson
                    {
                        Status = StatusType.OK,
                        Data = "Successfully edit channel"
                    }));
                }
                else
                {
                    return(Json(new NBCMSResultJson
                    {
                        Status = StatusType.Error,
                        Data = msg == string.Empty ? "faile to add new Channel" : msg
                    }));
                }
            }
            catch (Exception ex)
            {
                NBCMSLoggerManager.Fatal(ex.Message);
                NBCMSLoggerManager.Fatal(ex.StackTrace);
                NBCMSLoggerManager.Error("");
                return(Json(new NBCMSResultJson
                {
                    Status = StatusType.Exception,
                    Data = ex.Message
                }));
            }
        }
Example #4
0
        public List <Channel_Model> GetChannelList(Channel_Model queryModel, out int count)
        {
            using (PermaisuriCMSEntities db = new PermaisuriCMSEntities())
            {
                var query = db.Channel.AsQueryable();
                if (!string.IsNullOrEmpty(queryModel.ChannelName))
                {
                    //这种查询方式无效,即使是AsQueryable()。。。。2013年10月30日14:53:25 Lee
                    //query.Where(q => q.ChannelName.Contains(queryModel.ChannelName));
                    query = query.Where(q => q.ChannelName.Contains(queryModel.ChannelName));
                }
                if (!string.IsNullOrEmpty(queryModel.ShortName))
                {
                    query = query.Where(q => q.ShortName.Contains(queryModel.ShortName));
                }
                if (queryModel.queryAPI != 2)
                {
                    query = query.Where(q => q.API == (queryModel.queryAPI == 0 ? false : true));
                }
                if (queryModel.queryExport2CSV != 2)
                {
                    query = query.Where(q => q.API == (queryModel.queryExport2CSV == 0 ? false : true));
                }

                count = query.Count();
                query = query.OrderByDescending(q => q.ChannelID).Skip((queryModel.page - 1) * queryModel.rows).Take(queryModel.rows);
                return(query.Select(q => new Channel_Model
                {
                    ChannelID = q.ChannelID,
                    ChannelName = q.ChannelName,
                    ShortName = q.ShortName,
                    API = q.API,
                    Export2CSV = q.Export2CSV,
                    Modifier = q.Modifier,
                    Modify_Date = q.Modify_Date,
                    strModify_Date = q.Modify_Date.ToString("yyyy-MM-dd HH:mm:ss")
                }).ToList());
            }
        }
Example #5
0
        public bool EditChannel(Channel_Model model, string user, ref string msg)
        {
            using (PermaisuriCMSEntities db = new PermaisuriCMSEntities())
            {
                var isExist = db.Channel.FirstOrDefault(c => c.ChannelName == model.ChannelName);
                msg = string.Empty;
                if (isExist == null)
                {
                    msg = "This item does not exist";
                    return(false);
                }

                Channel entity = db.Channel.Where(a => a.ChannelID == model.ChannelID).FirstOrDefault();
                entity.API         = model.API;
                entity.ChannelName = model.ChannelName;
                entity.ShortName   = model.ShortName;
                entity.Export2CSV  = model.Export2CSV;
                entity.Modify_Date = DateTime.Now;
                entity.Modifier    = user;
                return(db.SaveChanges() > 0);
            }
        }
 public ActionResult GetChannelList(Channel_Model queryModel)
 {
     try {
         var cis   = new ChannelInfoServices();
         int count = 0;
         List <Channel_Model> list = cis.GetChannelList(queryModel, out count);
         return(Json(new NBCMSResultJson {
             Status = StatusType.OK,
             Data = new {
                 total = count,
                 rows = list
             }
         }));
     }
     catch (Exception ex) {
         NBCMSLoggerManager.Fatal(ex.Message);
         NBCMSLoggerManager.Fatal(ex.StackTrace);
         NBCMSLoggerManager.Error("");
         return(Json(new NBCMSResultJson {
             Status = StatusType.Exception,
             Data = ex.Message
         }));
     }
 }