Esempio n. 1
0
        public ActionResult Create([Bind(Include = "content_id,content_title,content_post,account_id,status,faculty_id,date_post,date_public,date_end")] content content)
        {
            int m              = DateTime.Now.Year;
            var closedate      = db.closuredates.Where(c => c.Year == m).Select(md => md.Closure_date).FirstOrDefault();
            var finalclosedate = db.closuredates.Where(c => c.Year == m).Select(md => md.Final_Closure_date).FirstOrDefault();

            StringBuilder sb = new StringBuilder();
            var           x  = RandomNumber(1, 99999);

            if (ModelState.IsValid)
            {
                sb.Append(content.faculty_id).Append(numberid(x));
                content.content_id = sb.ToString();

                content.date_post      = DateTime.Now;
                content.date_end       = closedate;
                content.date_final_end = finalclosedate;
                //content.date_end = DateTime.Now.AddDays(14);
                content.faculty_id = Session["accountFaculty"].ToString();
                content.account_id = Session["accountID"].ToString();
                content.status     = "Processing";
                db.contents.Add(content);
                db.SaveChanges();

                SendEmail(sb.ToString(), Session["accountID"].ToString(), content.content_title);


                return(RedirectToAction("Index"));
            }



            return(View(content));
        }
Esempio n. 2
0
        private XmlCacheFilePersister(IBackgroundTaskRunner <XmlCacheFilePersister> runner, content content, ProfilingLogger logger, bool touched)
        {
            _runner  = runner;
            _content = content;
            _logger  = logger;

            if (runner.TryAdd(this) == false)
            {
                _runner   = null; // runner's down
                _released = true; // don't mess with timer
                return;
            }

            // runner could decide to run it anytime now

            if (touched == false)
            {
                return;
            }

            _logger.Logger.Debug <XmlCacheFilePersister>("Created, save in {0}ms.", () => WaitMilliseconds);
            _initialTouch = DateTime.Now;
            _timer        = new Timer(_ => TimerRelease());
            _timer.Change(WaitMilliseconds, 0);
        }
        void InitialAndroid()  //推送安卓手机初始化。
        {
            CustomContent c = new CustomContent();

            c.MessageID   = MessageID;
            c.MessageText = MessageText;
            c.MessageType = "1";
            c.MessageTime = MessageTime.ToString("yyyy-MM-dd HH:mm:ss");
            c.Level       = "1";
            c.TergetType  = "ALARM";
            c.TergetID    = TergetID;

            messageAndroid m = new messageAndroid();

            m.title                    = title; //
            m.description              = MessageText;
            m.notification_builder_id  = 0;
            m.notification_basic_style = 1;
            m.custom_content           = c;

            content t = new content();

            t.channel_id  = channel_id;
            t.ApiKey      = this.ApiKey;
            t.SecretKey   = this.SecretKey;
            t.msg_type    = "1";
            t.device_type = "3"; // (Android = 3 ,Ios = 4)
            t.msg         = m.ToString();

            SendContent = t.ToString();
        }
Esempio n. 4
0
        public ActionResult Newspapers(string CountryID)
        {
            List <content>  paperslist   = new List <content>();
            List <language> languagelist = db.language.ToList();

            var list2 = db.content.Where(e => e.countrycode == "" + CountryID).ToList();

            var res = list2.Join(languagelist, a => a.languageid, b => b.languageid, (a, b) => new { a, b.name }).ToList();

            foreach (var item in res)
            {
                content objpaper = new content();
                objpaper.metakeywords    = item.a.title.Substring(0, 1);
                objpaper.id              = item.a.id;
                objpaper.title           = item.a.title;
                objpaper.url             = item.a.url;
                objpaper.logo            = item.a.logo;
                objpaper.id              = item.a.id;
                objpaper.languageid      = item.a.languageid;
                objpaper.continentid     = item.a.continentid;
                objpaper.metadescription = item.a.metadescription;
                objpaper.logo            = item.name;
                paperslist.Add(objpaper);
            }

            paperslist = paperslist.OrderBy(e => e.metakeywords).ToList();
            return(View(paperslist));
        }
        void InitialIos()  //推送苹果手机初始化。
        {
            aps aps = new BaiDuPush.aps();

            aps.alert            = title;
            aps.sound            = "default";
            aps.badge            = "0";
            aps.contentAvailable = 1;

            messageIos m = new messageIos();

            m.aps         = aps;
            m.MessageID   = MessageID;
            m.MessageText = MessageText;
            m.MessageType = "1";
            m.MessageTime = MessageTime.ToString("yyyy-MM-dd HH:mm:ss");
            m.Level       = "1";
            m.TergetType  = "ALARM";
            m.TergetID    = TergetID;

            content t = new content();

            t.channel_id  = channel_id;
            t.ApiKey      = this.ApiKey;
            t.SecretKey   = this.SecretKey;
            t.msg_type    = "1";
            t.device_type = "4"; // (Android = 3 ,Ios = 4)
            t.msg         = m.ToString();

            SendContent = t.ToString();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string mediaid = Request["mediaid"];
                Log(mediaid);
                string  pams = "{\"media_id\":\"" + mediaid + "\"}";
                string  data = RequestType.HttpPost("https://api.weixin.qq.com/cgi-bin/material/get_material?access_token=" + getAccessToken(), pams);
                content str  = JsonConvert.DeserializeObject <content>(data);

                if (str.errcode == 0)
                {
                    matlist = str;
                }
                else
                {
                    matlist = null;
                    msg     = data;
                    //Log(data);
                }
            }
            catch (Exception)
            {
                throw new Exception("参数错误");
            }
        }
Esempio n. 7
0
        protected void GetArticleOfDay()
        {
            content MyArticle = new content();

            if (object.Equals(Session["ArticleOfDay"], null))
            {
                List <int> MyList = App_Code.ContentService.GetContentIDList("EN");

                int AODCount = MyList.Count();

                int AODMax = AODCount;

                int rand = App_Code.RALTService.GetRandomNumber(0, AODMax);

                int MyContentID = MyList[rand];

                MyArticle = App_Code.ContentService.GetRandomContent(MyContentID, "EN");

                Session["ArticleOfDay"] = MyArticle;
            }
            else
            {
                MyArticle = (content)Session["ArticleOfDay"];
            }

            contentmarkup LatestVersion = new contentmarkup();

            LatestVersion = MyArticle.contentmarkups.FirstOrDefault <contentmarkup>();


            ArticleImage.ImageUrl        = MyArticle.image_url;
            ArticleTitleLink.Text        = MyArticle.title.Replace("-", " ");
            ArticleImageLink.NavigateUrl = "/" + MyArticle.category + "/" + "EN" + "/" + MyArticle.title;
            ArticleTitleLink.NavigateUrl = "/" + MyArticle.category + "/" + "EN" + "/" + MyArticle.title;
        }
        // PUT api/content/5
        public HttpResponseMessage Putcontent(string id, content content)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            if (id != content.contentid)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            db.Entry(content).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
Esempio n. 9
0
        public ActionResult Editpostcontent([FromForm] Updatepayload updatepayload)
        {
            SucceedInfomation succeedinfomation = new SucceedInfomation();
            //find postcontent metadata and use this metada to obtain post id and content id
            postcontent postcontentvalue = _Context.postcontents.FirstOrDefault(x => x.postid == updatepayload.postid);
            // find post id
            post postvalue = _Context.posts.FirstOrDefault(x => x.postid == postcontentvalue.postid);

            // insert new imgurl if imgfile payload not null
            if (updatepayload.imgfile != null)
            {
                // remove old file but that come later
                if (updatepayload.imgfile.FileName.EndsWith(".jpg"))
                {
                    postvalue.titleimgurl = _imgservice.SaveAsJPG(updatepayload.imgfile);
                }
                else if (updatepayload.imgfile.FileName.EndsWith(".png"))
                {
                    postvalue.titleimgurl = _imgservice.SaveAsPng(updatepayload.imgfile);
                }
            }
            // insert new value of postitle
            postvalue.posttitle = updatepayload.posttitle;
            // find content id
            content contentvalue = _Context.contents.FirstOrDefault(x => x.contentid == postcontentvalue.contentid);

            // insert new value of content
            contentvalue.contentdetail = updatepayload.contentdetail;
            // the Update operation start here
            //
            _Context.posts.Update(postvalue);
            _Context.contents.Update(contentvalue);
            _Context.SaveChanges();
            return(Ok(succeedinfomation));
        }
Esempio n. 10
0
        public Dictionary <string, string> getContentsANSIKey(string akey)
        {
            Dictionary <string, string> retDict = new Dictionary <string, string>();
            content cont = null;

            try
            {
                cont = db.contents.ToList().Where((c) => { return(c.ansiKey == akey); }).FirstOrDefault();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            if (cont == null)
            {
                retDict.Add("Error", "No record found");
                return(retDict);
            }
            else
            {
                retDict.Add("description", cont.description);
                retDict.Add("category", cont.category);
                retDict.Add("notes", cont.notes);
                retDict.Add("usage Region", cont.usageRegion);
                retDict.Add("aka", cont.AKA);
                retDict.Add("uncKey", cont.uncKey);
                retDict.Add("ansiKey", cont.ansiKey);
                // var json = Newtonsoft.Json.JsonConvert.SerializeObject(cont);
                //return Json(json);
                return(retDict);
            }
        }
Esempio n. 11
0
        private bool HandlePresContent(short code, byte[] content)
        {
            try
            {
                if (XcapService.IsSuccessCode(code))
                {
                    content presContent = this.Deserialize(content, typeof(content)) as content;
                    if (presContent != null && presContent.data != null && !String.IsNullOrEmpty(presContent.data.Value))
                    {
                        this.Avatar = presContent.data.Value;
                        return(true);
                    }
                }
                else if (code == 404)
                {
                    XcapService.LOG.Error("'org.openmobilealliance.pres-content' document not found");
                    return(true);
                }
            }
            catch (Exception e)
            {
                XcapService.LOG.Error("Fialed to handle 'org.openmobilealliance.pres-content' event", e);
                return(false);
            }

            return(false);
        }
Esempio n. 12
0
        // POST: contents/Delete/5


        // select pdf library
        public FileStreamResult DownloadZip(string id)
        {
            MemoryStream workStream = new MemoryStream();
            content      content    = db.contents.Find(id);
            // read parameters from the webpage
            string htmlString = content.content_post;


            string      pdf_page_size = "A4";
            PdfPageSize pageSize      = (PdfPageSize)Enum.Parse(typeof(PdfPageSize),
                                                                pdf_page_size, true);

            string             pdf_orientation = "Portrait";
            PdfPageOrientation pdfOrientation  =
                (PdfPageOrientation)Enum.Parse(typeof(PdfPageOrientation),
                                               pdf_orientation, true);

            int webPageWidth = 1024;

            try
            {
                webPageWidth = 1024;
            }
            catch { }

            int webPageHeight = 0;

            try
            {
                webPageHeight = 0;
            }
            catch { }

            // instantiate a html to pdf converter object
            HtmlToPdf converter = new HtmlToPdf();

            // set converter options
            converter.Options.PdfPageSize        = pageSize;
            converter.Options.PdfPageOrientation = pdfOrientation;
            converter.Options.WebPageWidth       = webPageWidth;
            converter.Options.WebPageHeight      = webPageHeight;

            // create a new pdf document converting an url
            SelectPdf.PdfDocument doc = converter.ConvertHtmlString(htmlString);

            byte[] pdf = doc.Save();
            doc.Close();
            // put pdf into zip
            using (var zip = new ZipFile())
            {
                zip.AddEntry(content.content_id + ".pdf", pdf);
                zip.Save(workStream);
            }
            workStream.Position = 0;
            FileStreamResult fileResult = new FileStreamResult(workStream, System.Net.Mime.MediaTypeNames.Application.Zip);

            fileResult.FileDownloadName = content.content_id + ".zip";
            return(fileResult);
        }
Esempio n. 13
0
 /// <summary>
 /// 简单检测邮件信息
 /// </summary>
 /// <param name="content">邮件信息</param>
 /// <returns>是否合法</returns>
 private bool check(content content)
 {
     return(content != null && content.Subject != null && content.Body != null && content.SendTo != null &&
            From != null && Password != null && Smtp.Server != null &&
            content.Subject.Length != 0 && content.Body.Length != 0 &&
            Password.Length != 0 && Smtp.Server.Length != 0 &&
            content.SendTo.IndexOf('@') > 0 && From.IndexOf('@') > 0);
 }
        public ActionResult DeleteConfirmed(int id)
        {
            content content = db.contents.Find(id);

            db.contents.Remove(content);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 15
0
        public bool CreatePresenceContentDocument(String base64Content, String mimeType)
        {
            if (String.IsNullOrEmpty(base64Content) || String.IsNullOrEmpty(mimeType))
            {
                LOG.Error("Invalid content or mimeType");
                return(false);
            }

            content document = new content();

            document.mimetype             = new contentMimetype();
            document.mimetype.Value       = mimeType;
            document.encoding             = new contentEncoding();
            document.encoding.Value       = "base64";
            document.description          = new contentDescription[1];
            document.description[0]       = new contentDescription();
            document.description[0].Value = "Doubango";
            document.data       = new contentData();
            document.data.Value = base64Content;

            String documentUrl;

            if (this.xcapDocumentsUris.ContainsKey(XcapService.XCAP_AUID_OMA_PRES_CONTENT_ID))
            {
                documentUrl = this.xcapDocumentsUris[XcapService.XCAP_AUID_OMA_PRES_CONTENT_ID];
            }
            else
            {
                lock (this.xcapSelector)
                {
                    this.xcapSelector.reset();
                    this.xcapSelector.setAUID(XcapService.XCAP_AUID_OMA_PRES_CONTENT_ID);
                    documentUrl = this.xcapSelector.getString();
                }
            }
            byte[] payload = this.Serialize(document, true, true, this.GetSerializerNSFromAUID(XcapService.XCAP_AUID_OMA_PRES_CONTENT_ID));

            MyXcapMessage xcapMessage = this.xcapStack.PutDocument(documentUrl, payload, (uint)payload.Length, XcapService.XCAP_AUID_OMA_PRES_CONTENT_MIME_TYPE);

            if (xcapMessage != null)
            {
                if (XcapService.IsSuccessCode(xcapMessage.Code))
                {
                    return(true);
                }
                else
                {
                    LOG.Error(String.Format("Failed to update statusicon with code={0}", xcapMessage.Code));
                }
            }
            else
            {
                LOG.Error("Failed to update statusicon");
            }

            return(false);
        }
        protected void GridContent_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int    Row   = e.RowIndex;
            string Title = (string)e.Keys[0];

            content MyContent = App_Code.ContentService.DeleteObjectByTitle(Title);

            BindContentGrid();
        }
Esempio n. 17
0
        //common lib
        public bool Insert_Content(content entity)
        {
            try
            {
                //process the alias

                //gắn giá trị nếu như rỗng ở các mục slug , keyword , description cho việc SEO sau này
                if (string.IsNullOrEmpty(entity.meta_title))
                {
                    entity.meta_title = StringHelper.ToUnsignString(entity.name);
                }
                if (string.IsNullOrEmpty(entity.seo_title))
                {
                    entity.seo_title = entity.name;
                }
                if (string.IsNullOrEmpty(entity.meta_keyword))
                {
                    entity.meta_keyword = entity.tag;
                }
                if (string.IsNullOrEmpty(entity.meta_description))
                {
                    entity.meta_description = entity.description_content;
                }

                entity.created_at  = DateTime.Now;
                entity.modified_at = DateTime.Now;
                entity.view_count  = 0;
                entity.share_count = 0;
                db.contents.Add(entity);
                db.SaveChanges();

                //process tag
                if (!string.IsNullOrEmpty(entity.tag))
                {
                    string[] tags = entity.tag.Split(',');
                    foreach (var tag in tags)
                    {
                        var tag_id     = StringHelper.ToUnsignString(tag);
                        var existedTag = this.Check_Tag(tag_id);

                        //insert to tag table
                        if (!existedTag)
                        {
                            this.Insert_Tag(tag_id, tag);
                        }
                        //insert to entity tag
                        this.Insert_ContentTag(entity.id, tag_id);
                    }
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
 public ActionResult Edit([Bind(Include = "id,title,introtext,fulltext,state,catid,created,create_by,image,ordering,hit")] content content)
 {
     if (ModelState.IsValid)
     {
         db.Entry(content).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(content));
 }
 public ActionResult Edit([Bind(Include = "idContent,contentCourse,dateCreation,userCreation,dateChange,userChange")] content content)
 {
     if (ModelState.IsValid)
     {
         db.Entry(content).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(content));
 }
Esempio n. 20
0
        public ActionResult About_Edit()
        {
            content content = db.contents.Find(21);

            if (content == null)
            {
                return(HttpNotFound());
            }
            return(View(content));
        }
Esempio n. 21
0
 public ActionResult About_Edit([Bind(Include = "id,introtext,fulltext")] content content)
 {
     if (ModelState.IsValid)
     {
         db.Entry(content).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(content));
 }
Esempio n. 22
0
        public bool Update_Content(content entity)
        {
            try
            {
                //process alias
                if (string.IsNullOrEmpty(entity.meta_title))
                {
                    entity.meta_title = StringHelper.ToUnsignString(entity.name);
                }

                var info = db.contents.Find(entity.id);
                info.name                = entity.name;
                info.meta_title          = entity.meta_title;
                info.description_content = entity.description_content;
                info.url_image           = entity.url_image;
                info.detail              = entity.detail;
                info.content_category_id = entity.content_category_id;
                info.tag              = entity.tag;
                info.seo_title        = entity.seo_title;
                info.modified_by      = entity.modified_by;
                info.modified_at      = DateTime.Now;
                info.meta_keyword     = entity.meta_keyword;
                info.meta_description = entity.meta_description;
                info.is_active        = entity.is_active;
                info.is_top_hot       = entity.is_top_hot;
                db.SaveChanges();

                //process tag
                if (!string.IsNullOrEmpty(entity.tag))
                {
                    this.RemoveAll_ContentTag(entity.id);
                    string[] tags = entity.tag.Split(',');
                    foreach (var tag in tags)
                    {
                        var tag_id     = StringHelper.ToUnsignString(tag);
                        var existedTag = this.Check_Tag(tag_id);

                        //insert to to tag table
                        if (!existedTag)
                        {
                            var resultTag = this.Insert_Tag(tag_id, tag);
                        }

                        //insert to entity tag
                        var resultcontentTag = this.Insert_ContentTag(entity.id, tag_id);
                    }
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
 public ActionResult Edit([Bind(Include = "content_id,content1,snippet,summary,content_image,archive,content_date,user_id")] content content)
 {
     if (ModelState.IsValid)
     {
         db.Entry(content).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.user_id = new SelectList(db.users, "user_id", "user_asp_id", content.user_id);
     return(View(content));
 }
Esempio n. 24
0
        // GET api/content/5
        public content Getcontent(string id)
        {
            content content = db.content.Find(id);

            if (content == null)
            {
                throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            return(content);
        }
Esempio n. 25
0
 public ActionResult Edit([Bind(Include = "content_id,content_title,content_post,account_id,status,faculty_id,date_post,date_public,date_end")] content content)
 {
     if (ModelState.IsValid)
     {
         db.Entry(content).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.account_id = new SelectList(db.accounts, "account_id", "account_name", content.account_id);
     ViewBag.faculty_id = new SelectList(db.faculties, "faculty_id", "faculty_name", content.faculty_id);
     return(View(content));
 }
Esempio n. 26
0
        public ActionResult Preview([Bind(Include = "content_id,content1,snippet,summary,title,content_image,archive,content_type,content_date,user_id")] content content)
        {
            if (ModelState.IsValid)
            {
                db.contents.Add(content);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.user_id = new SelectList(db.users, "user_id", "user_asp_id", content.user_id);
            return(View(content));
        }
        protected void AdministratorChangeLanguage()
        {
            try
            {
                string Content = ContentPlaceHolder.InnerHtml;
                //Retrieve ContentName from Session
                string ContentTitle = (string)ViewState["ContentTitle"];

                //Get Content Data
                content MyContent = new content();
                MyContent = App_Code.ContentService.GetObjectByTitle(ContentTitle);

                //Store Selected Language
                string SelectedLanguage = ddlContentLanguage.SelectedValue;

                //get Versions of this language if any
                int NumberOfVersions = App_Code.ContentService.GetMarkupByLanguage(MyContent.content_id, SelectedLanguage).Count();

                //Check for versions
                if (NumberOfVersions > 0)
                {
                    //Load page for this language
                    Response.Redirect("/" + MyContent.category + "/" + SelectedLanguage + "/" + ContentTitle);
                }

                else
                {
                    //Create this content in the selected language
                    contentmarkup MyMarkup = new contentmarkup();



                    MyMarkup.content_id  = MyContent.content_id;
                    MyMarkup.language    = SelectedLanguage;
                    MyMarkup.description = txtContentDescription.Text;
                    MyMarkup.markup      = Content.Replace("ContentSection editable", "ContentSection");

                    App_Code.ContentService.SaveContent(MyMarkup);

                    //Redirect to new language
                    Response.Redirect("/" + MyContent.category + "/" + SelectedLanguage + "/" + ContentTitle);
                }
            }



            catch (Exception ex)
            {
                //Error
                App_Code.NotificationService.SendNotification("LanguageChangeError", ex.Message, "error");
            }
        }
Esempio n. 28
0
        public List <content> GetContentList(string sql)
        {
            List <content> lp = new List <content>();

            using (DataTable dt = helper.GetDataTable(sql))
            {
                if (dt != null && dt.Rows.Count > 0)
                {
                    Dictionary <int, tClass> Dic = new _Class().getClassDicFObj();
                    foreach (DataRow r in dt.Rows)
                    {
                        content b = new content
                        {
                            id         = Convert.ToInt16(r["id"]),
                            cId        = Convert.ToInt16(r["cId"]),
                            cType      = Convert.ToInt16(r["cType"]),
                            title      = r["title"].ToString(),
                            contents   = r["contents"].ToString(),
                            isHot      = Convert.ToInt16(r["isHot"]),
                            isCheck    = Convert.ToInt16(r["isCheck"]),
                            adminId    = Convert.ToInt16(r["adminId"]),
                            checkId    = Convert.ToInt16(r["checkId"]),
                            cDate      = Convert.ToDateTime(r["cDate"]),
                            imgUrl     = r["imgUrl"].ToString(),
                            isHref     = Convert.ToInt16(r["isHref"]),
                            hrefUrl    = r["hrefUrl"].ToString(),
                            source     = r["source"].ToString(),
                            enable     = Convert.ToInt16(r["enable"]),
                            wp_tel     = r["wp_tel"].ToString(),
                            wp_addr    = r["wp_addr"].ToString(),
                            wp_contact = r["wp_contact"].ToString(),
                            addOn      = Convert.ToDateTime(r["AddOn"])
                        };
                        b.contents = StripHTML(b.contents);
                        if (b.contents.Length > 30)
                        {
                            b.contents = b.contents.Substring(0, 30);
                        }
                        if (b.imgUrl.Length == 0)
                        {
                            if (Dic.ContainsKey(b.cId))
                            {
                                b.imgUrl = Dic[b.cId].defaultUrl;
                            }
                        }
                        lp.Add(b);
                    }
                }
            }
            return(lp);
        }
        // GET: /Services/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            content content = db.contents.Find(id);

            if (content == null)
            {
                return(HttpNotFound());
            }
            return(View(content));
        }
Esempio n. 30
0
        public async Task <ActionResult <SucceedInfomation> > createpostcontent([FromForm] PostPayload postpayload)
        {
            SucceedInfomation succeedinformation = new SucceedInfomation();
            post Newpost = new post()
            {
                posttitle = postpayload.posttitle
            };

            if (postpayload.imgfile == null || postpayload.posttitle.Length < 3)
            {
                succeedinformation.Issucceed     = false;
                succeedinformation.SucceedDetail = "Please complete the form";
                return(Ok(succeedinformation));
            }
            if (postpayload.imgfile.FileName.EndsWith(".jpg"))
            {
                Newpost.titleimgurl = await _imgservice.SaveFileJpg(postpayload.imgfile);
            }
            else if (postpayload.imgfile.FileName.EndsWith(".png"))
            {
                Newpost.titleimgurl = await _imgservice.SaveFilePng(postpayload.imgfile);
            }
            // else if(postpayload.imgfile.Length  == 0)
            // {
            //  succeedinformation.Issucceed = false;
            //  succeedinformation.SucceedDetail = "file format invalide , pls use jpg or png";
            //  return Ok(succeedinformation);
            // }
            content Newcontent = new content()
            {
                contentdetail = postpayload.contentdetail
            };

            _Context.posts.Add(Newpost);
            _Context.contents.Add(Newcontent);
            _Context.SaveChanges();
            var Newposcontent = new postcontent()
            {
                postid             = Newpost.postid,
                contentid          = Newcontent.contentid,
                userid             = postpayload.userid,
                categoryid         = postpayload.categoryid,
                postcontentcreated = DateTime.UtcNow
            };

            _Context.postcontents.Add(Newposcontent);
            _Context.SaveChanges();
            return(succeedinformation);
        }
       public SQLiteOpenHelper(content.Context context, string name, SQLiteDatabase.CursorFactory factory, int version)
       {
 
       }