public ActionResult Edit(int id)
        {
            Video video = _videoServices.GetById(id);

            if (video == null)
            {
                AR.Setfailure(Messages.HttpNotFound);
                return(Json(AR, JsonRequestBehavior.AllowGet));
            }

            var vm = _mapper.Map <VideoIM>(video);

            var pageMeta = _pageMetaServices.GetPageMeta(ModelType.VIDEO, vm.Id.ToString());

            if (pageMeta != null)
            {
                vm.SEOTitle    = pageMeta.Title;
                vm.Keywords    = pageMeta.Keyword;
                vm.Description = pageMeta.Description;
            }

            var categorys  = _categoryServices.GetAll().OrderByDescending(m => m.Importance).ToList();
            var lCategorys = new SelectList(categorys, "Id", "Title");

            ViewBag.Categories = lCategorys;

            return(PartialView("_Edit", vm));
        }
Esempio n. 2
0
        public IActionResult VideoEdit(int?id)
        {
            var entity = _videoServices.GetById((int)id);

            var model = new VideoModel()
            {
                VideoId = entity.VideoId,
                Title   = entity.Title,
                Url     = entity.Url
            };

            return(View(model));
        }
Esempio n. 3
0
        public IActionResult VideoEditAdmin(int id)
        {
            var entity = _videoServices.GetById(id);
            var model  = new VideoModel()
            {
                VideoId = entity.VideoId,
                Tittle  = entity.Tittle,
                Url     = entity.Url,
                Date    = entity.Date
            };

            return(View(model));
        }
Esempio n. 4
0
 public ActionResult Update(int?id)
 {
     if (id.HasValue)
     {
         var model    = _videoService.GetById(id.Value);
         var category = _videoService.Dropdownlist(0, model.parentId);
         ViewBag.parentId = category.Select(x => new SelectListItem {
             Text = x.Text, Value = x.Value.ToString()
         });
         return(View(model));
     }
     return(RedirectToAction("Add"));
 }
Esempio n. 5
0
        public ActionResult VideoDetail(int Id)
        {
            var model = _videoServices.GetById(Id);

            ViewBag.Title = model.videoTitle;
            var _c = _categoryVideoServices.GetById(model.parentId ?? 0);

            if (_c != null)
            {
                ViewBag.Breadcrumb = "<a href=\"video-clip/" + _c.categoryId + "\">" + _c.categoryName + "</a> > " + model.videoTitle;
            }
            else
            {
                ViewBag.Breadcrumb = "<a href=\"video-clip\">Danh sách video</a> > " + model.videoTitle;
            }
            return(View(model));
        }
Esempio n. 6
0
        public async Task <HttpResponseMessage> ReservationVideo(int videoId)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.Unauthorized, "还未授权"));
            }
            var openId = User.Identity.Name;

            try
            {
                var video = _videoServices.GetById(videoId);

                if (video == null)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "不存在此视频!"));
                }

                var vm = new Reservation
                {
                    VideoId     = videoId,
                    OpenId      = openId.ToString(),
                    CreatedDate = DateTime.Now
                };

                var message = new SingleSendMessagesVM {
                    ToUser = openId.ToString(), MsgType = "text", Text = new Message {
                        Content = $"你已成功预约了直播:【{video.Title}】"
                    }
                };
                var returnMsg = "预约成功";

                var res = _reservationServices.GetById(vm.VideoId, vm.OpenId);

                if (res != null)
                {
                    _reservationServices.Delete(res);
                    message.Text = new Message {
                        Content = $"你已成功取消了直播:【{video.Title}】的预约"
                    };
                    returnMsg = "已取消预约";
                }
                else
                {
                    _reservationServices.Create(vm);
                }


                var json = JsonConvert.SerializeObject(message, Newtonsoft.Json.Formatting.Indented,
                                                       new JsonSerializerSettings {
                    ContractResolver = new LowercaseContractResolver()
                });

                HttpContent content = new StringContent(json);
                content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                string accesstoken;
                if (_cacheServices.IsSet("access_token"))
                {
                    accesstoken = (string)_cacheServices.Get("access_token");
                }
                else
                {
                    var atvm = await WeChatHepler.GetAccessTokenAsync(SettingsManager.WeiXin.AppId, SettingsManager.WeiXin.AppSecret);

                    accesstoken = atvm.access_token;
                    _cacheServices.Set("access_token", accesstoken, 120);
                }
                var result = await WeChatHepler.SingleSendMessagesAsync(accesstoken, content);

                _logger.Info($"单发结果[errcode:{result.ErrCode},errmsg:{result.ErrMsg}];消息主体:{json}");

                return(Request.CreateResponse(HttpStatusCode.OK, returnMsg));
            }
            catch (Exception ex)
            {
                _logger.Fatal(ex);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message, ex));
            }
        }