Beispiel #1
0
        public ContentResult GetMold(int id)
        {
            MoldRepository objMoldRepository = new MoldRepository(SessionCustom);

            objMoldRepository.Entity.MoldId = id;
            objMoldRepository.LoadByKey();

            XmlDocument objDoc = new XmlDocument();

            objDoc.LoadXml(objMoldRepository.Entity.Xmlcontent);
            string json = Newtonsoft.Json.JsonConvert.SerializeXmlNode(objDoc.ChildNodes[1]);

            return(new ContentResult()
            {
                Content = json,
                ContentType = "application/json"
            });
        }
Beispiel #2
0
        public ActionResult Create(NewsModel model, HttpPostedFileBase contentImage, List <string> videoyoutube, string existingTags, string newTags)
        {
            NewsRepository    objnews    = new NewsRepository(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);
                objnews.Entity = model.News;
                objnews.Entity.ExistingTags = !string.Empty.Equals(existingTags) ? existingTags : null;
                objnews.Entity.NewTags      = !string.Empty.Equals(newTags) ? newTags : null;

                if (objnews.Entity.ContentId != null)
                {
                    if (model.News.MoldId != null)
                    {
                        MoldRepository objMoldRepository = new MoldRepository(this.SessionCustom);
                        objMoldRepository.Entity.MoldId = model.News.MoldId;
                        objMoldRepository.LoadByKey();

                        XmlDocument objDoc = this.GetXmlInformation(objMoldRepository.Entity.Xmlcontent, objnews.Entity.ContentId.Value);
                        model.News.Xmlcontent = objDoc.InnerXml;
                    }

                    objnews.Update();
                    this.InsertAudit("Update", this.Module.Name + " -> " + model.IContent.Name);
                }
                else
                {
                    if (model.News.MoldId != null)
                    {
                        MoldRepository objMoldRepository = new MoldRepository(SessionCustom);
                        objMoldRepository.Entity.MoldId = model.News.MoldId;
                        objMoldRepository.LoadByKey();

                        XmlDocument objDoc = this.GetXmlInformation(objMoldRepository.Entity.Xmlcontent, objcontent.ObjContent.ContentId.Value);
                        model.News.Xmlcontent = objDoc.InnerXml;
                    }

                    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)));
                            }

                            if (!string.IsNullOrEmpty(objnews.Entity.Xmlcontent))
                            {
                                objnews.Entity.Xmlcontent = objnews.Entity.Xmlcontent.Replace(item, "/Files/" + objcontent.ObjContent.ContentId + "/" + Path.GetFileName(item));
                            }
                        }
                    }

                    objnews.Entity.ContentId = objcontent.ObjContent.ContentId;
                    objnews.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", "News", new { mod = Module.ModulId, id = objnews.Entity.ContentId }));
            }
        }