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)); } }
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)); }