コード例 #1
0
ファイル: Service1.cs プロジェクト: tcns/impulse
        public Models.AdModels.VideoUnit GetVideoById(string UserName, int Id)
        {
            VideoUnit videoUnit = context.VideoUnits.Find(Id);

            if (videoUnit == null)
            {
                throw new FaultException <VideoNotFoundException>(new VideoNotFoundException(Models.Properties.ExceptionText.VideoNotFoundById));
            }
            if (true)
            {
                return(videoUnit);
            }
            else
            {
                throw new FaultException <VideoNotFoundException>(new VideoNotFoundException(Models.Properties.ExceptionText.VideoNotFoundByUser));
            }
        }
コード例 #2
0
ファイル: UploadController.cs プロジェクト: tcns/impulse
        public async Task <HttpResponseMessage> SaveImage(VideoUnitDTO video)
        {
            byte[] image    = Convert.FromBase64String(video.Image);
            string path     = "/Videos/" + User.Identity.Name + "/" + video.GeneratedName + "/";
            string fullPath = HttpContext.Current.Server.MapPath("~" + path);

            if (!Directory.Exists(fullPath))
            {
                Directory.CreateDirectory(fullPath);
            }
            File.WriteAllBytes(fullPath + "/img.png", image);
            video.Image = path + "img.png";
            VideoUnit vid = Mapper.Map <VideoUnitDTO, VideoUnit>(video);
            string    id  = await service.SaveVideoAsync(vid);

            return(Request.CreateResponse(HttpStatusCode.OK, id));
        }