public ResourceInfo CreateResource(ResourceInfo resourceInfo)
        {
            _db.ResourceInfos.Add(resourceInfo);
            try
            {
                _db.SaveChanges();
            }
            catch (Exception ex)
            {

            }
            return resourceInfo;
        }
 public string MoveResources(FileInfo fileInfo, FileInfo thumbFileInfo, ResourceInfo resourceInfo)
 {
     var path = Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~/Resources/"), resourceInfo.Id.ToString());
     DirectoryInfo d = new DirectoryInfo(path);
     d.Create();
     var newFilePath = Path.Combine(d.ToString(), resourceInfo.ResourceName.ToString());
     var newThumbFilePath = Path.Combine(d.ToString(), resourceInfo.ThumbName);
     File.Move(fileInfo.FullName, newFilePath.ToString());
     File.Move(thumbFileInfo.FullName, newThumbFilePath.ToString());
     return path;
 }
 public bool UpdateResource(ResourceInfo resourceInfo)
 {
     _db.Entry(resourceInfo).State = System.Data.EntityState.Modified;
     try
     {
         _db.SaveChanges();
         return true;
     }
     catch (Exception ex)
     {
         return false;
     }
 }
 public ResourceInfo GetResourceInfoFromFormProvider(MultipartFormDataStreamProvider provider)
 {
     var resourceInfo = new ResourceInfo();
     resourceInfo.Title = !string.IsNullOrEmpty(provider.FormData.Get("Title")) ? string.Concat(provider.FormData.Get("Title")) : "";
     resourceInfo.Description = !string.IsNullOrEmpty(provider.FormData.Get("Description")) ? string.Concat(provider.FormData.Get("Description")) : "";
     resourceInfo.CategoryId = !string.IsNullOrEmpty(provider.FormData.Get("CategoryId")) ? Convert.ToInt32(provider.FormData.Get("CategoryId")) : 0;
     resourceInfo.Rank = !string.IsNullOrEmpty(provider.FormData.Get("Rank")) ? string.Concat(provider.FormData.Get("Rank")) : "";
     resourceInfo.CreateDate = DateTime.Now;
     string[] tags = provider.FormData.Get("Tags").Split(',');
     resourceInfo.Tags = new List<Tag>();
     foreach (var tag in tags)
     {
         if (tag != "")
         {
             var _tag = this.GetTagByTagName(tag);
             if (_tag == null)
             {
                 resourceInfo.Tags.Add(new Tag()
                 {
                     Name = tag
                 });
             }
             else
             {
                 resourceInfo.Tags.Add(_tag);
             }
         }
     }
     return resourceInfo;
 }