// GET: Admin/WebContentTypes/Create
        public async Task <ActionResult> Create()
        {
            var webContentType = new WebContentType();

            webContentType.MenuTypeList = WebContentManage.QueryMenuTypes(); // await _menuTypeDal.QueryAllAsync();
            return(View(webContentType));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult <WebContentType> > PostWebContentType(WebContentType webContentType)
        {
            _context.WebContentType.Add(webContentType);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetWebContentType", new { id = webContentType.WebContentTypeId }, webContentType));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> PutWebContentType(int id, WebContentType webContentType)
        {
            if (id != webContentType.WebContentTypeId)
            {
                return(BadRequest());
            }

            _context.Entry(webContentType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WebContentTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 4
0
        protected BaseItem CreateItem(ItemType type, XmlDocument document, string logTime)
        {
            BaseItem item = null;

            switch (type)
            {
            case ItemType.Unknown:
                item = new Unknown(document, logTime);
                break;

            case ItemType.Document:
                item = new Document(document, logTime);
                break;

            case ItemType.Rendition:
                item = new Rendition(document, logTime);
                break;

            case ItemType.LinkItem:
                item = new LinkItem(document, logTime);
                break;

            case ItemType.Folder:
                item = new Folder(document, logTime);
                break;

            case ItemType.DocumentSet:
                item = new DocumentSet(document, logTime);
                break;

            case ItemType.List:
                item = new List(document, logTime);
                break;

            case ItemType.Web:
                item = new Web(document, logTime);
                break;

            case ItemType.WebContentType:
                item = new WebContentType(document, logTime);
                break;

            case ItemType.Others:
                item = new Others(document, logTime);
                break;

            default:
                item = null;
                break;
            }
            return(item);
        }
        public async Task <ActionResult> Create(WebContentType webContentType)
        {
            if (!string.IsNullOrEmpty(webContentType.Name))
            {
                InitInsert(webContentType);
                await _webContentTypeDal.InsertAsync(webContentType);

                WebContentManage.RefreshWebContentTypes();
                return(RedirectToAction("Index"));
            }
            webContentType.MenuTypeList = WebContentManage.QueryMenuTypes();// await _menuTypeDal.QueryAllAsync();
            return(View(webContentType));
        }
        public async Task <ActionResult> Edit(WebContentType webContentType)
        {
            if (!string.IsNullOrEmpty(webContentType.Name))
            {
                InitModify(webContentType);
                await _webContentTypeDal.ModifyAsync(webContentType);

                WebContentManage.RefreshWebContentTypes();
                return(RedirectToAction("Index"));
            }
            webContentType.MenuType     = WebContentManage.QueryMenuTypeById(webContentType.MenuTypeId); // await _menuTypeDal.QueryByIdAsync(webContentType.MenuTypeId);
            webContentType.MenuTypeList = WebContentManage.QueryMenuTypes();                             // await _menuTypeDal.QueryAllAsync();
            return(View(webContentType));
        }
        // GET: Admin/WebContentTypes/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            WebContentType webContentType = WebContentManage.QueryWebContentTypeById((int)id);// await _webContentTypeDal.QueryByIdAsync(id);

            if (webContentType == null)
            {
                return(HttpNotFound());
            }
            webContentType.MenuType = WebContentManage.QueryMenuTypeById(webContentType.MenuTypeId);// await _menuTypeDal.QueryByIdAsync(webContentType.MenuTypeId);
            return(View(webContentType));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 模拟GET方法(默认编码UTF-8)
        /// </summary>
        /// <param name="url"></param>
        /// <param name="contentType">默认test/html</param>
        /// <param name="timeout">超时值 默认6000ms</param>
        /// <returns></returns>
        public static string HttpGet(string url, WebContentType contentType = WebContentType.Html, int timeout = 6000)
        {
            Encoding       encoding = Encoding.UTF8;
            HttpWebRequest request  = (HttpWebRequest)WebRequest.Create(url);

            request.Method      = "GET";
            request.ContentType = contentType.GetDescription() + ";charset=UTF-8";
            request.Timeout     = timeout;
            var response = ((HttpWebResponse)request.GetResponse()).GetResponseStream();

            if (response == null)
            {
                return(null);
            }
            using StreamReader reader = new StreamReader(response, encoding);
            return(reader.ReadToEnd());
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 模拟POST方法(默认编码UTF-8)
        /// </summary>
        /// <param name="url">请求url</param>
        /// <param name="body">post内容</param>
        /// <param name="contentType">所发消息的ContentType</param>
        /// <returns></returns>
        public static string HttpPost(string url, string body, WebContentType contentType = WebContentType.General)
        {
            Encoding       encoding = Encoding.UTF8;
            HttpWebRequest request  = (HttpWebRequest)WebRequest.Create(url);

            request.Method = "POST";
            //request.Accept = "text/html, application/xhtml+xml, */*";
            request.ContentType = contentType.GetDescription();

            byte[] buffer = encoding.GetBytes(body);
            request.ContentLength = buffer.Length;
            request.GetRequestStream().Write(buffer, 0, buffer.Length);
            var response = ((HttpWebResponse)request.GetResponse()).GetResponseStream();

            if (response == null)
            {
                return(null);
            }
            using StreamReader reader = new StreamReader(response, encoding);
            return(reader.ReadToEnd());
        }