Esempio n. 1
0
        public static T Find(string id)
        {
            if (id == null)
            {
                return(null);
            }
            var fullPath = Path.Combine(Config.FilesPath, id);

            if (File.Exists(fullPath))
            {
                return(SerializeDeserializeHelper.DeSerializeObject <T>(fullPath));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
 public void Save()
 {
     if (!String.IsNullOrWhiteSpace(Id) && Find(Id) != null)
     {
         return; //TODO: Get entity from _db and Update properties
     }
     else
     {
         //Genetare Id only if we don't have one
         if (String.IsNullOrWhiteSpace(this.Id))
         {
             Id = Guid.NewGuid().ToString();
         }
         var savePath = Path.Combine(Config.FilesPath, Id);
         SerializeDeserializeHelper.SerializeObject(this, savePath);
     }
 }