Ejemplo n.º 1
0
        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;
                        _videoService.Add(model);
                        _videoService.Save();
                        _serviceLog.Add(new ActionLog {
                            actionLogStatus = 1, actionLogTime = DateTime.Now, actionLogType = 1, actionNote = "Thêm mới video Id:" + model.videoId, userIp = "", userName = User.Identity.Name
                        });
                        _serviceLog.Save(); return(RedirectToAction("Index"));
                    }
                }
                catch (Exception ex)
                {
                }
            }
            var category = _videoService.Dropdownlist(0, model.parentId);

            ViewBag.parentId = category.Select(x => new SelectListItem {
                Text = x.Text, Value = x.Value.ToString()
            });
            return(View(model));
        }