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 }));
        }
        public void InsertOrUpdate(CategoryIntro categoryIntro)
        {
            var model = _context.CategoryIntroes.Find(categoryIntro.Id);

            if (categoryIntro.Id == default(int))
            {
                // New entity
                _context.CategoryIntroes.Add(categoryIntro);
            }
            else
            {
                // Existing entity
                _context.Entry(model).State         = EntityState.Detached;
                _context.Entry(categoryIntro).State = EntityState.Modified;
            }
        }
 public DbPropertyEntry GetProperty <TProperty>(CategoryIntro categoryIntro, Expression <Func <CategoryIntro, TProperty> > property)
 {
     return(_context.Entry(categoryIntro).Property(property));
 }
 public void Load <TElement>(CategoryIntro categoryIntro, Expression <Func <CategoryIntro, ICollection <TElement> > > includeProperty) where TElement : class
 {
     _context.CategoryIntroes.Attach(categoryIntro);
     _context.Entry(categoryIntro).Collection(includeProperty).Load();
 }