public ActionResult Create(HttpPostedFileBase thumbnailFile, CategoryIntro categoryIntro)
        {
            if (thumbnailFile != null && thumbnailFile.ContentLength > 0)
            {
                string extension           = Path.GetExtension(thumbnailFile.FileName);
                string timeUpload          = DateTime.Now.ToString("yyyyMMddHHmmss");
                string fileName            = Convert.ToInt32((DateTime.Now - new DateTime(2010, 01, 01)).TotalSeconds) + "_" + thumbnailFile.FileName;
                string currentDomain       = System.Configuration.ConfigurationManager.AppSettings["CurrentDomain"];
                string folder              = "UploadedImages/VideoThumbnail";
                string physicalStoragePath = System.Configuration.ConfigurationManager.AppSettings[currentDomain];
                string filePath            = physicalStoragePath + @"\" + folder + @"\" + fileName;

                using (new Impersonator("uploaduser", "", "Upload@@123"))
                {
                    thumbnailFile.SaveAs(filePath);
                }
                categoryIntro.Thumbnail = currentDomain + "/" + folder + "/" + fileName;
            }

            ModelState.Clear();
            TryValidateModel(categoryIntro);

            if (ModelState.IsValid)
            {
                _categoryIntroRepository.InsertOrUpdate(categoryIntro);
                _categoryIntroRepository.Save();
                VideoCategory category = _categoryRepository.Find(categoryIntro.VideoCategoryId);
                return(Json(new { success = true, groupid = category.GroupId, catid = category.Id }));
            }
            //ViewBag.VideoCategoryId = new SelectList(_categoryRepository.All.ToList(), "Id", "Name");
            ViewBag.VideoCatGroups = _videoCatGroupRepository.AllIncluding(v => v.VideoCats).OrderBy(v => v.Order).ToList();
            var viewStr = this.RenderRazorViewToString("Create", categoryIntro);

            return(Json(new { success = false, view = viewStr }));
        }
Пример #2
0
        public ActionResult GetItemCombineReport(int id, DateTime?from, DateTime?to, string dateType = "week")
        {
            //string data = Utilities.RenderRazorViewToString(this, "/Views/VideoAccess/GetItemCombineReport.cshtml", null);
            ViewBag.dateType = dateType;
            ViewBag.fromDate = from != null?from.Value.Date.ToString("dd/MM/yyyy") : "";

            ViewBag.toDate = to != null?to.Value.Date.ToString("dd/MM/yyyy") : "";

            var catvideo = _videoCatRepository.Find(id);

            ViewBag.image = catvideo == null ? "" : catvideo.ProfilePhoto;
            return(PartialView(id));
        }
Пример #3
0
        public ViewResult Details(string title)
        {
            int curType   = 0;
            var ortherCat = new VideoCategory();

            if (title.StartsWith("into-") || title.StartsWith("xay-dung-") || title.StartsWith("xuat-nhap-khau-"))
            {
                curType = 1;
                if (!title.EndsWith("-cuoi-tuan"))
                {
                    ortherCat = _videocategoryRepository.All.Where(v => v.UniqueTitle.StartsWith(title) && v.UniqueTitle.EndsWith("-cuoi-tuan")).First();
                }
                else
                {
                    var _otitle = title.Replace("-cuoi-tuan", "");
                    ortherCat = _videocategoryRepository.All.Where(v => v.UniqueTitle == _otitle).First();
                }
            }

            ViewBag.curType   = curType;
            ViewBag.ortherCat = ortherCat;

            return(View(_videocategoryRepository.Find(title)));
        }