/// <summary>
 /// Deprecated Method for adding a new object to the Resources EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToResources(Resources resources)
 {
     base.AddObject("Resources", resources);
 }
Пример #2
0
 public ActionResult EditResources(Resources rs)
 {
     var resource = DBContext.Resources.SingleOrDefault(e => e.Id == rs.Id);
     string category = string.Empty;
     if (rs.Type == 2)
         category = "链接";
     else if (rs.Type == 1)
     {
         switch (Path.GetExtension(rs.Uri).ToLower().Replace(".", ""))
         {
             case "ppt":
             case "pptx":
                 category = "幻灯";
                 break;
             case "doc":
             case "docx":
                 category = "文档";
                 break;
             case "xls":
             case "xlsx":
                 category = "Excel";
                 break;
             case "avi":
             case "wmv":
                 category = "视频";
                 break;
             default:
                 category = "其它";
                 break;
         }
     }
     else
         category = "应用程序";
     resource.Type = rs.Type;
     resource.Category = category;
     resource.Uri = rs.Uri;
     resource.Remark = rs.Remark;
     resource.Approve = rs.Approve;
     resource.CreateTime = rs.CreateTime;
     resource.Name = rs.Type == 2 ? rs.Uri : Path.GetFileNameWithoutExtension(rs.Uri);
     DBContext.SaveChanges();
     return RedirectToAction("IndexResources");
 }
 /// <summary>
 /// Create a new Resources object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="type">Initial value of the Type property.</param>
 /// <param name="uri">Initial value of the Uri property.</param>
 /// <param name="remark">Initial value of the Remark property.</param>
 /// <param name="createTime">Initial value of the CreateTime property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 public static Resources CreateResources(global::System.Int32 id, global::System.Int32 type, global::System.String uri, global::System.String remark, global::System.DateTime createTime, global::System.String name)
 {
     Resources resources = new Resources();
     resources.Id = id;
     resources.Type = type;
     resources.Uri = uri;
     resources.Remark = remark;
     resources.CreateTime = createTime;
     resources.Name = name;
     return resources;
 }
Пример #4
0
 public ActionResult AddResources(Resources rs)
 {
     if (ModelState.IsValid)
     {
         string type = Request.Form["Type"];
         string category = string.Empty;
         if (type == "2")
             category = "链接";
         else if (type == "3")
         {
             category = "应用程序";
         }
         else
         {
             switch (Path.GetExtension(Request.Form["FilePath"]).ToLower().Replace(".", ""))
             {
                 case "ppt":
                 case "pptx":
                     category = "幻灯";
                     break;
                 case "doc":
                 case "docx":
                     category = "文档";
                     break;
                 case "xls":
                 case "xlsx":
                     category = "Excel";
                     break;
                 case "avi":
                 case "wmv":
                     category = "视频";
                     break;
                 case "pdf":
                     category = "PDF";
                     break;
                 default:
                     category = "其它";
                     break;
             }
         }
         Resources res = new Resources();
         res.Type = int.Parse(type);
         res.Approve = false;
         res.Remark = rs.Remark == null ? "" : rs.Remark;
         res.Uri = type == "1" ? Request.Form["FilePath"] : Request.Form["url"];
         if (type == "3")
             res.Uri = Request.Form["exepath"];
         res.CreateTime = DateTime.Now;
         res.Category = category;
         res.Name = type == "1" ? Path.GetFileNameWithoutExtension(Request.Form["FilePath"]) : Request.Form["url"];
         if (type == "3")
             res.Name = Path.GetFileNameWithoutExtension(Request.Form["exepath"]);
         DBContext.Resources.AddObject(res);
         DBContext.SaveChanges();
         return RedirectToAction("IndexResources");
     }
     return View();
 }