private void SavePoster(HttpPostedFileBase[] files, int filmId)
        {
            if (files == null || filmId == 0)
            {
                return;
            }

            var image = files[0];

            if (image != null)
            {
                DirectoryTools.CheckDirectoryExist(ImageOptions.PATH);

                var posters = posterSrv[filmId];
                DeletePoster(posters);

                var poster = new PosterImageEntity
                {
                    FilmId   = filmId,
                    MaxImage = ImageResize
                               .Resize(image, ImageOptions.PATH, ImageOptions.IMAGE_WIDTH_MAX_VERTICAL, ImageOptions.IMAGE_HEIGHT_MAX_VERTICAL),
                    MinImage = ImageResize
                               .Resize(image, ImageOptions.PATH, ImageOptions.IMAGE_WIDTH_MIN_VERTICAL, ImageOptions.IMAGE_HEIGHT_MIN_VERTICAL)
                };

                posterSrv.Add(poster);
            }
        }
Example #2
0
        /// <summary>
        /// Update the information of an answer
        /// </summary>
        /// <param name="id">answer id</param>
        /// <param name="txtanswer">answer text</param>
        /// <param name="fileanswer">answer file</param>
        /// <returns>returns the result to action</returns>
        public ActionResult UpdateAnswer(int id, string txtanswer, HttpPostedFileBase fileanswer)
        {
            AnswerRepository objanswer = new AnswerRepository(SessionCustom);

            objanswer.Entity.AnswerId = id;
            objanswer.LoadByKey();
            string strfile = objanswer.Entity.Image;

            if (fileanswer != null)
            {
                strfile = DateTime.Now.ToString("ddmmyyyyhhmmssFFF") + Path.GetExtension(fileanswer.FileName);
                string filePath = @"Files/" + objanswer.Entity.ContentId.ToString() + "/" + strfile;
                string fullPath = Path.Combine(Server.MapPath("~"), filePath);
                fileanswer.SaveAs(fullPath);

                ImageResize objimage = new ImageResize(Server.MapPath("~"));
                objimage.Prefix = "_";
                objimage.Width  = 255;
                objimage.Height = 130;
                bool resized = objimage.Resize(filePath, ImageResize.TypeResize.CropProportional);
                if (resized)
                {
                    System.IO.File.Delete(fullPath);
                    System.IO.File.Move(Path.Combine(Server.MapPath("~"), @"Files/" + objanswer.Entity.ContentId.ToString() + "/_" + strfile), fullPath);
                }
            }

            objanswer.Entity.Text  = txtanswer;
            objanswer.Entity.Image = strfile;

            objanswer.Update();
            this.InsertAudit("Update", this.Module.Name + " -> Answer" + id);
            return(this.View("AnswerDetail", objanswer.Entity));
        }
        /// <summary>
        /// Creates a resized version of the source image using the default resampler.
        /// </summary>
        public static Image <TPixel> Resize <TPixel, TState>(
            this ReadOnlyPixelRowsContext <TPixel> context,
            Size size,
            TState state = default,
            ProcessingProgressCallback <TState>?onProgress = null)
            where TPixel : unmanaged, IPixel <TPixel>
        {
            //var inputImg = context.Image;
            //var outputImg = new Image<TPixel>(width, height);
            //
            //StbImageResize.stbir_resize(
            //    inputImg, inputImg.Width, inputImg.Height, inputImg.Stride, outputImg,
            //    outputImg.Width, outputImg.Height, outputImg.Stride, )

            var source = context.ToImage <Color>();
            var output = Image <Color> .CreateUninitialized(size);

            var progressCallback = onProgress == null ? (ResizeProgressCallback?)null :
                                   (p, r) => onProgress !.Invoke(state, p, r.ToMGRect());

            ImageResize.Resize(
                MemoryMarshal.AsBytes(source.GetPixelSpan()), source.Width, source.Height, source.ByteStride,
                MemoryMarshal.AsBytes(output.GetPixelSpan()), output.Width, output.Height, output.ByteStride,
                numChannels: 4,
                progressCallback);

            return(Image.LoadPixels <TPixel>(output));
        }
Example #4
0
 /// <summary>
 /// 调整图片的尺寸
 /// </summary>
 /// <param name="maxWidth">最大宽度</param>
 /// <param name="maxHeight">最大高度</param>
 /// <param name="isSameRate">是否保持比率</param>
 /// <returns></returns>
 public ImageWrapper Resize(int maxWidth, int maxHeight, bool isSameRate = false)
 {
     using (var stream = new MemoryStream(this.ImageBytes.ToArray()))
     {
         ImageSize imageSize = new ImageSize(maxWidth, maxHeight);
         byte[]    newBytes  = ImageResize.Resize(stream, imageSize, isSameRate);
         return(new ImageWrapper(newBytes));
     }
 }
Example #5
0
        public ActionResult Company(OrgRegisterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                var errors = ModelState.Select(x => x.Value.Errors)
                             .Where(y => y.Count > 0)
                             .ToList();

                ViewBag.ListСlassifikate = new SelectList(classifierService.GetAll.ToList(), "Id", "Name");
                return(View(model));
            }

            AppUser user = new AppUser
            {
                UserName          = model.Email,
                Email             = model.Email,
                LockoutEnabled    = true,
                LockoutEndDateUtc = DateTime.Now.AddHours(7)
            };



            IdentityResult identResult = UserManager.Create(user, model.Password);

            if (!identResult.Succeeded)
            {
                AddErrorsFromResult(identResult);
                ViewBag.ListСlassifikate = new SelectList(classifierService.GetAll.ToList(), "Id", "Name");
                return(View(model));
            }
            model.SmallPathImage = ImageResize.Resize(model.LogoFile, AppConstants.directoryProfileAvatar, 40, 40);
            model.LargePathImage = ImageResize.Resize(model.LogoFile, AppConstants.directoryProfileAvatar, 135, 135);
            model.OwnerId        = user.Id;
            UserManager.AddToRole(user.Id, RoleConstant.RoleCompany);
            orgService.Edit(OrganizationMapper.ToEntity(model));
            profileService.Edit(UserProfileMapper.ToEntity(model));



#if _DEBUG
            SignInManager.SignIn(user, model.RememberMe, false);
            return(Redirect("~/"));
#endif

#if _RELEASE
            string token = UserManager.GenerateEmailConfirmationToken(user.Id);
            SendEmail(new EmailVerify
            {
                CallbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, token = token }),
                cid         = Guid.NewGuid().ToString(),
                UserName    = user.UserName
            }, user.Id);

            return(View("TwoFactorMessage"));
#endif
        }
Example #6
0
        public ActionResult Detail(int?id, Usuarios model, HttpPostedFileBase userimage, List <int> colrols)
        {
            CustomMemberShipProvider objCustom  = new CustomMemberShipProvider(SessionCustom, HttpContext);
            RolUserRepository        objuserrol = new RolUserRepository(SessionCustom);

            model.UserCustom.LanguageId = 2;

            if (model.UserCustom.Password != null)
            {
                model.UserCustom.Password = Utils.EncriptSHA1(model.UserCustom.Password);
            }

            if (userimage != null && userimage.ContentLength > 0)
            {
                string userImage = Utils.UploadFile(
                    userimage,
                    HttpContext.Server.MapPath("~"),
                    @"resources\imagesuser\",
                    null);

                ImageResize objresize = new ImageResize(HttpContext.Server.MapPath("~"));
                objresize.Width  = 100;
                objresize.Height = 95;
                objresize.Prefix = "_";
                objresize.Resize(@"resources\imagesuser\" + userImage, ImageResize.TypeResize.BackgroundProportional);

                System.IO.File.Delete(System.IO.Path.Combine(HttpContext.Server.MapPath("~"), @"resources\imagesuser\" + userImage));
                model.UserCustom.Image = "_" + userImage;
            }

            if (id != null)
            {
                objuserrol.Entity.UserId = model.UserCustom.UserId = id;
                objCustom.ChangeData(model.UserCustom);
                objuserrol.Delete();
            }
            else
            {
                model.UserCustom.Joindate = DateTime.Now;
                objuserrol.Entity.UserId  = objCustom.CreateUser(model.UserCustom);
            }

            if (colrols != null)
            {
                foreach (int item in colrols)
                {
                    objuserrol.Entity.RolId = item;
                    objuserrol.Insert();
                }
            }

            return(this.RedirectToAction("Index", "Usuarios"));
        }
Example #7
0
        public string UploadAvatar()
        {
            HttpPostedFileBase file = Request.Files["Avatar"];

            DirectoryTools.CheckDirectoryExist(AppConstants.directoryProfileAvatar);
            string ownerId   = User.Identity.GetUserId();
            var    path      = ImageResize.Resize(file, AppConstants.directoryProfileAvatar, 135, 135);
            var    smallPath = ImageResize.Resize(file, AppConstants.directoryProfileAvatar, 40, 40);

            if (UserManager.IsInRole(ownerId, RoleConstant.RoleCompany))
            {
                var company = orgSrv.GetById(GetCurrentUser().Id);

                if (company != null)
                {
                    if (!string.IsNullOrEmpty(company.LargePathImage))
                    {
                        DirectoryTools.DeleteFile(HttpContext, company.LargePathImage, AppConstants.directoryProfileAvatar);
                    }

                    if (!string.IsNullOrEmpty(company.SmallPathImage))
                    {
                        DirectoryTools.DeleteFile(HttpContext, company.SmallPathImage, AppConstants.directoryProfileAvatar);
                    }

                    company.LargePathImage = path;
                    company.SmallPathImage = smallPath;

                    orgSrv.Edit(company);
                }
            }
            else
            {
                var userPicture = userSrv.Get(GetCurrentUser().Id);

                if (!string.IsNullOrEmpty(userPicture.PicturePath))
                {
                    DirectoryTools.DeleteFile(HttpContext, userPicture.PicturePath, AppConstants.directoryProfileAvatar);
                }

                userSrv.UploadAvatar(path, GetCurrentUser());
            }



            return(AppConstants.directoryProfileAvatar + path);
        }
Example #8
0
        private async Task <ServiceResult <object> > CreateThumbnail(IFormFile formFile, FileDto fileDto, BusinessParam bp)
        {
            var methodName = $".{new StackTrace().GetFrame(1).GetMethod().Name}";

            try
            {
                var webRootPath = bp.Environment.WebRootPath;
                var dto         = new FileDto
                {
                    Alt                  = fileDto.Alt,
                    DataSize             = fileDto.DataSize,
                    Description          = fileDto.Description,
                    DisplayInFileManager = false,
                    Extension            = fileDto.Extension,
                    FullTitle            = fileDto.FullTitle,
                    Name                 = fileDto.Name,
                    ParentId             = fileDto.ParentId,
                    Path                 = fileDto.Path,
                    Thumbnail            = fileDto.Thumbnail,
                    Title                = fileDto.Title
                };
                var resize = new ImageResize();
                resize.Resize(webRootPath + dto.Path, webRootPath + dto.Thumbnail);
                dto.DisplayInFileManager = false;
                dto.Path = dto.Thumbnail;
                var file = Copier.GetEntity(dto, bp, true);
                using (var unitOfWork = new UnitOfWork())
                {
                    var done = unitOfWork.File.Insert(file);
                    unitOfWork.File.Save();
                    if (!done)
                    {
                        return(ExceptionUtil.ExceptionHandler("خطا در ذخیره فایل درون دیتابیس",
                                                              ClassDetails[0].Facade + methodName,
                                                              bp.UserInfo));
                    }
                    Elastic <FileDto, DataLayer.Model.Core.File.File> .SaveToElastic(file, ClassDetails[0].Clazz, bp);

                    dto.EntityId = file.EntityId;
                    return(new ServiceResult <object>(dto, 1));
                }
            }
            catch (Exception e)
            {
                return(ExceptionUtil.ExceptionHandler(e, ClassDetails[0].Facade + methodName, bp.UserInfo));
            }
        }
Example #9
0
        public ActionResult Edit(OrganizationViewModel model)
        {
            model.IsInRole = User.IsInRole;

            if (ModelState.IsValid)
            {
                if (model.ImgFile != null)
                {
                    DirectoryTools.CheckDirectoryExist(AppConstants.directoryProfileAvatar);

                    var entity = orgService.GetById(model.Id);
                    if (entity != null)
                    {
                        if (entity.SmallPathImage != null)
                        {
                            DirectoryTools.DeleteFile(HttpContext, entity.SmallPathImage);
                        }

                        if (entity.LargePathImage != null)
                        {
                            DirectoryTools.DeleteFile(HttpContext, entity.LargePathImage);
                        }
                    }

                    model.SmallPathImage = ImageResize.Resize(model.ImgFile, AppConstants.directoryProfileAvatar, 50, 50);
                    model.LargePathImage = ImageResize.Resize(model.ImgFile, AppConstants.directoryProfileAvatar, 250, 250);
                }

                var result = orgService.Edit(OrganizationMapper.ToEntity(model));
                if (result != null)
                {
                    return(RedirectToAction("Index", "Organization"));
                }
            }
            ViewBag.ListСlassifikate = new SelectList(classifierService.GetAll.ToList(), "Id", "Name");
            return(View(model));
        }
Example #10
0
        private void SavePreviewPictrures(HttpPostedFileBase[] files, int articleId, string alt, bool isHeader = false)
        {
            if (files != null && files.Length <= 4)
            {
                if (files[0] != null)
                {
                    int smWidth = 150, smHeight = 150, lgWidth = 280, lgHeight = 280;

                    DirectoryTools.CheckDirectoryExist(AppConstants.dirNewsPreview);

                    var pics = newsSrv.GetPictures.Where(x => x.ArticleId == articleId);

                    DeletePreviewPictures(pics, articleId);

                    foreach (HttpPostedFileBase pic in files)
                    {
                        lgHeight = 280;
                        lgWidth  = 280;

                        if (isHeader)
                        {
                            lgWidth  = 1920;
                            lgHeight = 720;
                            smWidth  = 450;
                            smHeight = 290;
                        }

                        isHeader = false;

                        string smSize = ImageResize.Resize(pic, AppConstants.dirNewsPreview, smWidth, smHeight, true),
                               lgSize = ImageResize.Resize(pic, AppConstants.dirNewsPreview, lgWidth, lgHeight, true);

                        newsSrv.SavePicture(articleId, smSize, lgSize, $"{alt}");
                    }
                }
            }
        }
Example #11
0
        /// <summary>
        /// Inserts a content in data base
        /// </summary>
        /// <param name="content">the object content</param>
        public void ContentInsert(Content content)
        {
            this.ObjContent = content;
            string            serverMap  = this.context.Server.MapPath("~");
            ContentRepository objcontent = new ContentRepository(this.session);

            this.objimagerez             = new ImageResize(serverMap);
            objcontent.Entity            = this.ObjContent;
            objcontent.Entity.Updatedate = DateTime.Now;

            if (this.ContentImage != null && this.ContentImage.ContentLength > 0 && Utils.IsImage(this.ContentImage.FileName))
            {
                objcontent.Entity.Image = Utils.UploadFile(
                    this.ContentImage,
                    serverMap,
                    @"resources\temporal\",
                    null);
            }

            if (this.ContentCoverImage != null && this.ContentCoverImage.ContentLength > 0 && Utils.IsImage(this.ContentCoverImage.FileName))
            {
                objcontent.Entity.CoverImage = Utils.UploadFile(
                    this.ContentCoverImage,
                    serverMap,
                    @"resources\temporal\",
                    "cover-",
                    1800);
            }

            if (content.ContentId != null)
            {
                objcontent.Update();

                FriendlyurlRepository friendlyrepo = new FriendlyurlRepository(this.session);
                friendlyrepo.Entity.Id            = content.ContentId;
                friendlyrepo.Entity.Friendlyurlid = objcontent.Entity.Frienlyname;
                friendlyrepo.Entity.Type          = Friendlyurl.FriendlyType.Content;
                friendlyrepo.Entity.LanguageId    = content.LanguageId;
                friendlyrepo.Update();
            }
            else
            {
                objcontent.Entity.Orderliness = objcontent.GetMaxOrder();
                objcontent.Entity.Frienlyname = Utils.GetFindFrienlyName(this.session, objcontent.Entity.Name, objcontent.Entity.Orderliness.Value);
                objcontent.Entity.Joindate    = objcontent.Entity.Updatedate;

                if (content.UserId == null)
                {
                    objcontent.Entity.UserId = (this.context.User as CustomPrincipal).UserId;
                }
                else
                {
                    objcontent.Entity.UserId = content.UserId;
                }

                this.ObjContent.ContentId = Convert.ToInt32(objcontent.Insert());

                FriendlyurlRepository friendlyrepo = new FriendlyurlRepository(this.session);
                friendlyrepo.Entity.Id            = this.ObjContent.ContentId;
                friendlyrepo.Entity.Friendlyurlid = objcontent.Entity.Frienlyname;
                friendlyrepo.Entity.Type          = Friendlyurl.FriendlyType.Content;
                friendlyrepo.Entity.LanguageId    = content.LanguageId;
                friendlyrepo.Insert();
            }

            if (objcontent.Entity.Image != null)
            {
                string pathtruncate = Path.Combine(serverMap, @"resources\temporal\");
                string pathorigin   = pathtruncate + objcontent.Entity.Image;
                string newpath      = Path.Combine(serverMap, @"files\" + this.ObjContent.ContentId + @"\");

                if (File.Exists(pathorigin))
                {
                    int  newWidth  = 0;
                    int  newHeight = 0;
                    bool isResized = false;

                    if (int.TryParse(this.context.Request.Form["imgwidth"], out newWidth) &&
                        int.TryParse(this.context.Request.Form["imgheight"], out newHeight))
                    {
                        ImageResize objimage = new ImageResize(serverMap);

                        objimage.Prefix = "_";
                        objimage.Width  = newWidth;
                        objimage.Height = newHeight;
                        isResized       = objimage.Resize(@"resources\temporal\" + objcontent.Entity.Image, ImageResize.TypeResize.BackgroundProportional);
                    }

                    if (!Directory.Exists(newpath))
                    {
                        Directory.CreateDirectory(newpath);
                    }

                    if (!isResized)
                    {
                        File.Move(pathorigin, newpath + objcontent.Entity.Image);
                        File.Delete(pathorigin);
                    }
                    else
                    {
                        File.Move(pathtruncate + "_" + objcontent.Entity.Image, newpath + objcontent.Entity.Image);
                        File.Delete(pathorigin);
                        File.Delete(pathtruncate + "_" + objcontent.Entity.Image);
                    }
                }

                string fileroute = @"files\" + this.ObjContent.ContentId + @"\" + objcontent.Entity.Image;

                this.objimagerez.Resize(
                    fileroute,
                    ImageResize.TypeResize.PartialProportional);

                this.objimagerez.Width  = 170;
                this.objimagerez.Height = 105;
                this.objimagerez.Prefix = "170x105-";
                this.objimagerez.Resize(fileroute, ImageResize.TypeResize.CropProportional);

                this.objimagerez.Width  = 340;
                this.objimagerez.Height = 250;
                this.objimagerez.Prefix = "340x250-";
                this.objimagerez.Resize(fileroute, ImageResize.TypeResize.CropProportional);

                this.objimagerez.Width  = 340;
                this.objimagerez.Height = 320;
                this.objimagerez.Prefix = "340x320-";
                this.objimagerez.Resize(fileroute, ImageResize.TypeResize.CropProportional);

                this.objimagerez.Width  = 511;
                this.objimagerez.Height = 320;
                this.objimagerez.Prefix = "511x320-";
                this.objimagerez.Resize(fileroute, ImageResize.TypeResize.CropProportional);

                this.objimagerez.Width  = 683;
                this.objimagerez.Height = 320;
                this.objimagerez.Prefix = "683x320-";
                this.objimagerez.Resize(fileroute, ImageResize.TypeResize.CropProportional);

                this.objimagerez.Width  = 191;
                this.objimagerez.Height = 191;
                this.objimagerez.Prefix = "191x191-";
                this.objimagerez.Resize(fileroute, ImageResize.TypeResize.CropProportional);

                this.objimagerez.Width  = 511;
                this.objimagerez.Height = 255;
                this.objimagerez.Prefix = "511x255-";
                this.objimagerez.Resize(fileroute, ImageResize.TypeResize.CropProportional);
            }

            if (objcontent.Entity.CoverImage != null)
            {
                string pathtruncate = Path.Combine(serverMap, @"resources\temporal\");
                string pathorigin   = pathtruncate + objcontent.Entity.CoverImage;
                string newpath      = Path.Combine(serverMap, @"files\" + this.ObjContent.ContentId + @"\");

                if (File.Exists(pathorigin))
                {
                    if (!Directory.Exists(newpath))
                    {
                        Directory.CreateDirectory(newpath);
                    }

                    File.Move(pathtruncate + objcontent.Entity.CoverImage, newpath + objcontent.Entity.CoverImage);
                    File.Delete(pathorigin);
                    File.Delete(pathtruncate + objcontent.Entity.CoverImage);
                }

                string fileroute = @"files\" + this.ObjContent.ContentId + @"\" + objcontent.Entity.CoverImage;

                ////this.objimagerez.Resize(fileroute, ImageResize.TypeResize.PartialProportional);

                this.objimagerez.Width  = 1800;
                this.objimagerez.Height = 800;
                this.objimagerez.Prefix = "1800x800-";
                this.objimagerez.Resize(fileroute, ImageResize.TypeResize.Proportional);
            }

            this.InsertAttachFiles();
            this.InsertTags();
        }
 private void DeviceWorker_ImageChanged(object sender, ImageChangedEventArgs e)
 {
     this.Picture.Image = ImageResize.Resize(e.Img, this.Picture.Width, this.Picture.Height);
 }
Example #13
0
        public override void Sync()
        {
            string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            // Before we go any further, check to make sure the nfo File isnt malformed.
            try
            {
                XPathDocument docNav = new XPathDocument(this.Directory.ToString());
            }
            catch
            {
                // If its bad looking, meh.
                return;
            }

            DirectoryInfo nfoDirectory = this.Directory.Directory;

            string fullMovieName = this.Directory.Name.Replace(".nfo", "");
            string shortMovieName = fullMovieName.Replace("-", "").Replace(" ", "_").Replace("'", "").Replace("&", "_");
            shortMovieName = shortMovieName.Replace(".", "").Replace("(", "").Replace(")", "").Replace("__", "");
            shortMovieName = shortMovieName.Replace(",", "");

            // Copy the poster JPG if we can.
            if (File.Exists(nfoDirectory + "\\folder.jpg"))
            {

                string newFolderImage = appDataPath + "\\Microsoft\\eHome\\DvdCoverCache\\" + shortMovieName + ".jpg";

                if (File.Exists(newFolderImage))
                {
                    File.Delete(newFolderImage);
                }

                ImageResize imageResize = new ImageResize(nfoDirectory + "\\folder.jpg");
                // imageResize.Resize(newFolderImage, 230, 320, true);
                imageResize.Resize(newFolderImage, 130, 120, true);

            }

            // Delete source XML file if it exists.
            string soureXMLFile = nfoDirectory + "\\" + fullMovieName + ".xml";

            if (File.Exists(soureXMLFile))
            {
                File.Delete(soureXMLFile);
            }

            // Create local source XML file.
            XmlDocument xmlDoc = ConvertNFOToXML(fullMovieName, shortMovieName);
            xmlDoc.Save(soureXMLFile);

            // Delete XML file in DvdInfoCache if it exits.

            string cachedXMLFile = appDataPath + "\\Microsoft\\eHome\\DvdInfoCache\\" + fullMovieName + ".xml";

            if (File.Exists(cachedXMLFile))
            {
                File.Delete(cachedXMLFile);
            }

            // Copy local source XML file to Dvd Info Cache
            File.Copy(soureXMLFile, cachedXMLFile);

            // Delete local .dvdid XML file if it exists.
            string localDvdIDFile = nfoDirectory + "\\" + fullMovieName + ".dvdid.xml";

            if (File.Exists(localDvdIDFile))
            {
                File.Delete(localDvdIDFile);
            }

            // Create local .dvdid XML file if it exists.

            TextWriter dvdIdStream = new StreamWriter(localDvdIDFile);
            dvdIdStream.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            dvdIdStream.WriteLine("<DISC>");
            dvdIdStream.WriteLine("  <NAME>" + fullMovieName + "</NAME>");
            dvdIdStream.WriteLine("  <ID>" + fullMovieName + "</ID>");
            dvdIdStream.WriteLine("</DISC>");
            dvdIdStream.Close();
        }
Example #14
0
        public ActionResult Create(QuestionModel model, HttpPostedFileBase contentImage, HttpPostedFileBase contentCoverImage, List <string> videoyoutube, List <string> txtanswer, List <HttpPostedFileBase> fileanswer, string existingTags, string newTags)
        {
            QuestionRepository objquestion = new QuestionRepository(this.SessionCustom);
            ContentManagement  objcontent  = new ContentManagement(this.SessionCustom, HttpContext);

            try
            {
                DateTime?currentEndDate = null;
                if (model.IContent.ContentId.HasValue)
                {
                    objquestion.Entity.ContentId = model.IContent.ContentId;
                    objquestion.LoadByKey();
                    currentEndDate     = objquestion.Entity.EndDate;
                    objquestion.Entity = new Domain.Entities.Question();
                }

                objcontent.ContentImage      = contentImage;
                objcontent.ContentCoverImage = contentCoverImage;
                objcontent.CollVideos        = videoyoutube;
                this.SessionCustom.Begin();

                model.IContent.LanguageId = CurrentLanguage.LanguageId;
                objcontent.ContentInsert(model.IContent);
                objquestion.Entity = model.Question;
                objquestion.Entity.ExistingTags = !string.Empty.Equals(existingTags) ? existingTags : null;
                objquestion.Entity.NewTags      = !string.Empty.Equals(newTags) ? newTags : null;

                if (objquestion.Entity.ContentId != null)
                {
                    objquestion.Update();

                    bool reactivated = false;
                    if (currentEndDate < DateTime.Now.Date && model.Question.EndDate >= DateTime.Now.Date)
                    {
                        reactivated = true;
                    }

                    if (reactivated)
                    {
                        ContentRepository content = new ContentRepository(SessionCustom);
                        content.Entity.ContentId = model.Question.ContentId;
                        content.LoadByKey();
                        Business.Utilities.Notification.StartReActivateProcess(content.Entity.Frienlyname, content.Entity.ContentId.Value, this.HttpContext, this.CurrentLanguage);
                    }

                    this.InsertAudit("Update", this.Module.Name + " -> " + model.IContent.Name);
                }
                else
                {
                    if (!string.IsNullOrEmpty(Request.Form["TempFiles"]))
                    {
                        string[] files = Request.Form["TempFiles"].Split(',');

                        if (files.Length > 0)
                        {
                            if (!Directory.Exists(Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\")))
                            {
                                Directory.CreateDirectory(Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\"));
                            }
                        }

                        foreach (var item in files)
                        {
                            string filep = Path.Combine(Server.MapPath("~"), @"Files\Images\" + Path.GetFileName(item));
                            if (System.IO.File.Exists(filep))
                            {
                                ////string filedestin = Path.Combine(Server.MapPath("~"), @"Files\Images\" + Path.GetFileName(item));
                                string filedestin = Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\" + Path.GetFileName(item));
                                string fileroute  = @"Files\" + objcontent.ObjContent.ContentId + @"\" + Path.GetFileName(item);
                                System.IO.File.Move(filep, filedestin);
                            }
                        }
                    }

                    objquestion.Entity.ContentId = objcontent.ObjContent.ContentId;
                    objquestion.Insert();

                    ContentRepository content = new ContentRepository(SessionCustom);
                    content.Entity.ContentId = model.Question.ContentId;
                    content.LoadByKey();

                    ////EmailNotificationRepository emailNotification = new EmailNotificationRepository(SessionCustom);
                    ////List<int> users = emailNotification.SendNewProcessNotification();
                    ////foreach (int userId in users)
                    ////{
                    ////    Business.Utilities.Notification.NewNotification(userId, Domain.Entities.Basic.EmailNotificationType.NEW_PROCESS, null, null, string.Concat("/", content.Entity.Frienlyname), content.Entity.ContentId, content.Entity.ContentId.Value, null, null, null, this.SessionCustom, this.HttpContext, this.CurrentLanguage);
                    ////}

                    Business.Utilities.Notification.StartNewProcess(content.Entity.Frienlyname, content.Entity.ContentId.Value, this.HttpContext, this.CurrentLanguage);

                    this.InsertAudit("Insert", this.Module.Name + " -> " + model.IContent.Name);
                }

                if (objquestion.Entity.Type.Equals(Domain.Entities.Question.TypeQuestion.Seleccion_Multiple) && txtanswer != null)
                {
                    AnswerRepository objanswer = new AnswerRepository(this.SessionCustom);

                    for (int i = 0; i < txtanswer.Count; i++)
                    {
                        string strfile  = null;
                        string strvideo = null;
                        if (fileanswer[i] != null)
                        {
                            strfile = DateTime.Now.ToString("ddmmyyyyhhmmssFFF") + Path.GetExtension(fileanswer[i].FileName);
                            string filePath = @"Files/" + objquestion.Entity.ContentId.ToString() + "/" + strfile;
                            string fullPath = Path.Combine(Server.MapPath("~"), filePath);
                            fileanswer[i].SaveAs(fullPath);

                            ImageResize objimage = new ImageResize(Server.MapPath("~"));
                            objimage.Prefix = "_";
                            objimage.Width  = 255;
                            objimage.Height = 130;
                            bool resized = objimage.Resize(filePath, ImageResize.TypeResize.CropProportional);
                            if (resized)
                            {
                                System.IO.File.Delete(fullPath);
                                System.IO.File.Move(Path.Combine(Server.MapPath("~"), @"Files/" + objquestion.Entity.ContentId.ToString() + "/_" + strfile), fullPath);
                            }
                        }

                        objanswer.Entity = new Domain.Entities.Answer()
                        {
                            ContentId = objquestion.Entity.ContentId,
                            Count     = 0,
                            Text      = txtanswer[i],
                            Image     = strfile,
                            Video     = strvideo
                        };
                        objanswer.Insert();
                    }
                }

                this.SessionCustom.Commit();
            }
            catch (Exception ex)
            {
                SessionCustom.RollBack();
                Utils.InsertLog(
                    this.SessionCustom,
                    "Error" + this.Module.Name,
                    ex.Message + " " + ex.StackTrace);
            }

            if (Request.Form["GetOut"] == "0")
            {
                return(this.RedirectToAction("Index", "Content", new { mod = Module.ModulId }));
            }
            else
            {
                return(this.RedirectToAction("Detail", "Question", new { mod = Module.ModulId, id = objquestion.Entity.ContentId }));
            }
        }