Пример #1
0
        public ActionResult Edit(int id, string content, string url)
        {
            if (id <= 0)
            {
                ViewBag.ErrorMessage = "消息编码错误";
                return this.View("ShowError");
            }

            try
            {
                var service = new MessageService();
                var originalMsg = service.Single(id);

                if (originalMsg == null)
                {
                    ViewBag.ErrorMessage = "消息编码错误";
                    return this.View("ShowError");
                }

                originalMsg.Message1 = content;
                originalMsg.PicUrl = url;

                service.Update(originalMsg);

                return this.RedirectToAction("Index");
            }
            catch (Exception exception)
            {
                ViewBag.ErrorMessage = exception.InnerException;
                return this.View("ShowError");
            }
        }
Пример #2
0
        public ActionResult Edit(int id)
        {
            if (id <= 0)
            {
                ViewBag.ErrorMessage = "消息编码错误";
                return this.View("ShowError");
            }

            var message = new MessageService().Single(id);

            return this.View(message);
        }
Пример #3
0
        public ActionResult Remove(int id)
        {
            if (id <= 0)
            {
                ViewBag.ErrorMessage = "消息编码错误";
                return this.View("ShowError");
            }

            try
            {
                var service = new MessageService();
                var originalMsg = service.Single(id);

                if (originalMsg == null)
                {
                    ViewBag.ErrorMessage = "消息编码错误";
                    return this.View("ShowError");
                }

                originalMsg.State = 127;

                service.Update(originalMsg);

                return this.RedirectToAction("Index");
            }
            catch (Exception exception)
            {
                ViewBag.ErrorMessage = exception.InnerException;
                return this.View("ShowError");
            }
        }
Пример #4
0
        //
        // GET: /Message/
        public ActionResult Index()
        {
            var uid = Session["UID"];
            if (uid == null)
            {
                ViewBag.ErrorMessage = "用户ID为空,请确认您是否已授权。";
                return this.View("ShowError");
            }

            var list = new MessageService().GetMessages(1, 10, int.Parse(Session["UID"].ToString()));
            return View(list);
        }