public ActionResult add(VideoAddViewModel _model) { if (ModelState.IsValid) { Video video = new Video() { Title = _model.Title, CommentNum = 0, ZanNum = 0, CreateTime = DateTime.Now, Img = _model.Img, Src = _model.Src }; video = videoBll.Add(video); if (video.Id > 0) { return(RedirectToAction("list")); } else { ModelState.AddModelError("", "添加失败!"); } } return(View()); }
public ActionResult Add(Video model, HttpPostedFileBase fileVideo) { if (ModelState.IsValid) { try { if (fileVideo.ContentLength > 0) { string _fileName = Path.GetFileName(fileVideo.FileName); string _path = Path.Combine(Server.MapPath("~/FileVideo"), _fileName); fileVideo.SaveAs(_path); model.videoBody = _fileName; _Service.Add(model); _Service.Save(); return(RedirectToAction("Index")); } } catch (Exception ex) { } } ViewBag.languageId = _toolAdmin.LanguageSelectList(); ViewBag.Quanlyvideo = "active"; return(View(model)); }
public ApiResult Add([FromBody] VideoModel videoModel) { UserModel userModel = Auth.GetLoginUser(_httpContext); videoModel.AuthorAccount = userModel.Account; _videoService.Add(videoModel); return(ApiResult.Success()); }
public IActionResult Add(Video video) { var result = _videoService.Add(video); if (result.Succcess) { return(Ok(result)); } return(BadRequest(result)); }
public JsonResult Post(string Video) { string message = string.Empty; var jsonObj = new JavaScriptSerializer(); var model = jsonObj.Deserialize <Video>(Video); _VideoService.Add(model); _VideoService.Save(); message = ResultState.Add_SUCCESS; return(Json(new { message = message, status = true, }, JsonRequestBehavior.AllowGet)); }
public IActionResult PostVideo([FromBody] ResponseObject responseObject) { if (responseObject == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var json = JsonConvert.SerializeObject(responseObject.Data); var videoDTO = JsonConvert.DeserializeObject <VideoDTO>(json); videoDTO.Id = _videoService.Add(videoDTO); var response = new ResponseObject { Data = videoDTO }; return(Ok(response)); }
public ActionResult <ItemResponse <int> > Create(VideoAddRequest model) { ObjectResult result = null; try { int userId = _authService.GetCurrentUserId(); int id = _service.Add(model, userId); ItemResponse <int> response = new ItemResponse <int>() { Item = id }; result = Created201(response); } catch (Exception ex) { Logger.LogError(ex.ToString()); ErrorResponse response = new ErrorResponse(ex.Message); result = StatusCode(500, response); } return(result); }
public void Search(ClientEntities.Directory dir) { FileInfo[] files = null; DirectoryInfo[] subDirs = null; DirectoryInfo root = new DirectoryInfo(dir.Path); files = root.GetFiles(); if (files != null) { foreach (FileInfo fi in files) { /// Add to specific list(Casted) String extension = Path.GetExtension(fi.FullName); if (MusicExtensions.Contains(extension)) { musicService.Add(new Music(fi.FullName, fi.Name), dirId); } else if (VideoExtensions.Contains(extension)) { videoService.Add(new Video(fi.FullName, fi.Name), dirId); } else if (PictureExtensions.Contains(extension)) { imageService.Add(new Image(fi.FullName, fi.Name), dirId); } } subDirs = root.GetDirectories(); foreach (DirectoryInfo dirInfo in subDirs) { Search(new ClientEntities.Directory(dirInfo.Name, dirInfo.FullName)); } } }
public async Task <ActionResult <Video> > Create( [FromServices] IVideoService VideoService, [FromBody] Video video) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { await VideoService.Add(video); return(video); } catch (InvalidOperationException ex) { return(BadRequest(new { message = ex.Message })); } catch { return(BadRequest(new { message = Messages.NAO_FOI_POSSIVEL_CRIAR_O_VIDEO })); } }