Beispiel #1
0
        public ActionResult Create(ChallengeModel model, HttpPostedFileBase contentImage, HttpPostedFileBase contentCoverImage, List <string> videoyoutube, string existingTags, string newTags)
        {
            ChallengeRepository objchallenge = new ChallengeRepository(this.SessionCustom);
            ContentManagement   objcontent   = new ContentManagement(this.SessionCustom, HttpContext);

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

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

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

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

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

                    if (reactivated)
                    {
                        ContentRepository content = new ContentRepository(SessionCustom);
                        content.Entity.ContentId = model.Challenge.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));
                                System.IO.File.Move(filep, Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\" + Path.GetFileName(item)));
                            }
                        }
                    }

                    objchallenge.Entity.ContentId = objcontent.ObjContent.ContentId;
                    objchallenge.Entity.Followers = 0;
                    objchallenge.Insert();

                    ContentRepository content = new ContentRepository(SessionCustom);
                    content.Entity.ContentId = model.Challenge.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);
                }

                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", "Challenge", new { mod = Module.ModulId, id = objchallenge.Entity.ContentId }));
            }
        }
Beispiel #2
0
        public ActionResult Create(EmailNotificationTemplateModel model, HttpPostedFileBase contentImage, List <string> videoyoutube, string existingTags, string newTags)
        {
            EmailNotificationTemplateRepository objnotification = new EmailNotificationTemplateRepository(this.SessionCustom);
            ContentManagement objcontent = new ContentManagement(this.SessionCustom, HttpContext);

            try
            {
                objcontent.ContentImage = contentImage;
                objcontent.CollVideos   = videoyoutube;
                this.SessionCustom.Begin();

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

                if (objnotification.Entity.ContentId != null)
                {
                    objnotification.Update();
                    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));
                                System.IO.File.Move(filep, Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\" + Path.GetFileName(item)));
                            }
                        }
                    }

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

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

                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", "EmailNotification", new { mod = Module.ModulId, id = objnotification.Entity.ContentId }));
            }
        }
Beispiel #3
0
        public ActionResult Create(BlogEntryModel model, string contentImage, List <string> videoyoutube)
        {
            Business.Services.CustomPrincipal currentUserInfo = (Business.Services.CustomPrincipal)User;
            if (Utils.IsBlogAdmin(currentUserInfo.UserId))
            {
                BlogEntryRepository objblogentry = new BlogEntryRepository(this.SessionCustom);
                ContentManagement   objcontent   = new ContentManagement(this.SessionCustom, HttpContext);

                try
                {
                    model.IContent.Template = "BlogEntry";
                    model.IContent.Widget   = false;
                    model.IContent.Private  = false;
                    model.IContent.Active   = true;
                    model.IContent.Image    = contentImage;

                    objcontent.CollVideos = videoyoutube;
                    this.SessionCustom.Begin();

                    model.IContent.LanguageId = 2;
                    objcontent.ContentInsert(model.IContent, 4);
                    objblogentry.Entity = model.BlogEntry;
                    if (objblogentry.Entity.ContentId != null)
                    {
                        objblogentry.Update();
                        this.InsertAudit("Update", this.Module.Name + " -> " + model.IContent.Name);
                    }
                    else
                    {
                        objblogentry.Entity.ContentId = objcontent.ObjContent.ContentId;
                        objblogentry.Insert();

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

                    string serverMap = Server.MapPath("~");
                    string origin    = serverMap + @"\resources\temporal\blog\" + contentImage;
                    if (System.IO.File.Exists(origin))
                    {
                        if (!System.IO.Directory.Exists(serverMap + @"\files\" + objblogentry.Entity.ContentId))
                        {
                            System.IO.Directory.CreateDirectory(serverMap + @"\files\" + objblogentry.Entity.ContentId);
                        }

                        System.IO.File.Move(origin, serverMap + @"\files\" + objblogentry.Entity.ContentId + @"\" + contentImage);
                    }

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

                return(this.View("index", model));
            }

            return(null);
        }
Beispiel #4
0
        public ActionResult Create(SuccessStoryModel model, HttpPostedFileBase contentImage, HttpPostedFileBase contentCoverImage, List <string> videoyoutube, string existingTags, string newTags)
        {
            SuccessStoryRepository objSuccessStory = new SuccessStoryRepository(this.SessionCustom);
            ContentManagement      objcontent      = new ContentManagement(this.SessionCustom, HttpContext);

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

                model.IContent.LanguageId = CurrentLanguage.LanguageId;
                objcontent.ContentInsert(model.IContent, 4);
                objSuccessStory.Entity = model.SuccessStory;
                objSuccessStory.Entity.ExistingTags = !string.Empty.Equals(existingTags) ? existingTags : null;
                objSuccessStory.Entity.NewTags      = !string.Empty.Equals(newTags) ? newTags : null;

                if (objSuccessStory.Entity.ContentId != null)
                {
                    objSuccessStory.Update();
                    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));
                                System.IO.File.Move(filep, Path.Combine(Server.MapPath("~"), @"Files\" + objcontent.ObjContent.ContentId + @"\" + Path.GetFileName(item)));
                            }
                        }
                    }

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

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

                this.SessionCustom.Commit();

                if (model.PostulateId != null)
                {
                    SuccessStoryPostulateFacade dbpostulate = new SuccessStoryPostulateFacade();
                    Domain.Entities.Generic.SuccessStoryPostulate postulate = dbpostulate.GetById(model.PostulateId.Value, this.CurrentLanguage.LanguageId.Value);
                    postulate.SuccessStoryId = objcontent.ObjContent.ContentId;
                    postulate.State          = (int)Domain.Entities.Enums.SuccessStoryPostulateStateEnum.Published;
                    if (dbpostulate.Update(postulate))
                    {
                        string domainUrl = string.Format("/SuccessStory/Story/{0}", objcontent.ObjContent.ContentId.Value);
                        this.SendUserNotification(postulate.UserId, domainUrl, objcontent.ObjContent.ContentId.Value);
                    }

                    this.InsertAudit("Update Postulate", this.Module.Name + " -> " + model.IContent.Name);
                }
            }
            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", "SuccessStory", new { mod = Module.ModulId, id = objSuccessStory.Entity.ContentId }));
            }
        }
Beispiel #5
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 }));
            }
        }