コード例 #1
0
        public HttpResponseMessage AddVideo(VideoInfo videoDto)
        {
            try
            {
                Requires.NotNull("videoDto", videoDto);
                Requires.NotNegative("videoDto.CourseId", videoDto.CourseId);
                Requires.NotNegative("videoDto.ModuleId", videoDto.ModuleId);
                Requires.NotNegative("videoDto.OrderIndex", videoDto.OrderIndex);
                Requires.NotNegative("videoDto.CreatedByUserId", videoDto.CreatedByUserId);
                Requires.NotNegative("videoDto.LastModifiedByUserId", videoDto.LastModifiedByUserId);

                if (UserInfo.IsInRole(PortalSettings.AdministratorRoleName))
                {
                    var vc = new VideoController();

                    // get the video from the database to maintain data integrity
                    var video = vc.GetVideo(videoDto.VideoId, videoDto.ModuleId);

                    if (video == null)
                    {
                        // this is a new video
                        // update all values
                        video = new VideoInfo()
                        {
                            VimeoId              = videoDto.VimeoId,
                            CourseId             = videoDto.CourseId,
                            ModuleId             = videoDto.ModuleId,
                            OrderIndex           = videoDto.OrderIndex,
                            CreatedByUserId      = videoDto.CreatedByUserId,
                            LastModifiedByUserId = videoDto.LastModifiedByUserId,
                            LastModifiedOnDate   = DateTime.Now,
                            CreatedOnDate        = DateTime.Now
                        };

                        vc.CreateVideo(video);
                    }
                    else
                    {
                        // this is an existing video that's getting updated
                        // we'll only update the values that are allowed to be updated
                        video.VimeoId              = videoDto.VimeoId;
                        video.CourseId             = videoDto.CourseId;
                        video.OrderIndex           = videoDto.OrderIndex;
                        video.LastModifiedByUserId = videoDto.LastModifiedByUserId;
                        video.LastModifiedOnDate   = DateTime.Now;

                        vc.UpdateVideo(video);
                    }
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc));
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(Request.QueryString["VideoId"]))
            {
                _videoInfo = _videoController.GetVideo(Int32.Parse(Request.QueryString["VideoId"]));
            }

            if (Page.IsPostBack)
            {
                return;
            }

            LoadTime();

            if (_videoInfo.VideoId != -1)
            {
                RenderForm();
            }
        }