Example #1
0
        public StrokesModule() : base("/strokes")
        {
            //commentss
            Get["/forehand"] = parameters =>
            {
                var viewModel = new StrokesViewModel();

                return(View["strokes", viewModel]);
            };

            Get["/backhand"] = parameters =>
            {
                var viewModel = new StrokesViewModel();

                return(View["strokes", viewModel]);
            };

            Get["/serve"] = parameters =>
            {
                var viewModel = new StrokesViewModel();

                viewModel.UserStrokeUrl = "https://tennisvids.blob.core.windows.net/serves/WP_20130706_003.mp4";

                return(View["strokes", viewModel]);
            };

            Get["/upload"] = parameters =>
            {
                var viewModel = new StrokesViewModel();

                return(View["upload", viewModel]);
            };

            Post["/upload"] = parameters =>
            {
                var viewModel  = new StrokesViewModel();
                var strokesDto = new StrokeDto();

                var file = this.Request.Files.FirstOrDefault();

                if (file != null)
                {
                    strokesDto.UserId      = 1;
                    strokesDto.StrokeVideo = file.Value;
                    strokesDto.StrokeType  = (StrokeType)((int)Request.Form.StrokeType);
                    strokesDto.StrokeAngle = (StrokeAngle)((int)Request.Form.StrokeAngle);

                    var strokesBizObj = new Strokes();
                    strokesBizObj.UploadStroke(strokesDto);

                    viewModel.IsSuccessfulUpload = true;
                }
                else
                {
                }

                return(View["upload", viewModel]);
            };
        }