summaryrefslogtreecommitdiff
path: root/dsa/DSALib/Commands/FileHandler.cs
diff options
context:
space:
mode:
authorDennis Kobert <d-kobert@web.de>2019-06-11 23:38:13 +0200
committerDennis Kobert <d-kobert@web.de>2019-06-11 23:38:13 +0200
commit2fa4a0e50ebfc97059c8b84dbd17e79f9afc8a8d (patch)
treec3b34ccb2737e347a73768536895cbbaab13cc01 /dsa/DSALib/Commands/FileHandler.cs
parentec991104f56e90d7bb2878da2fe6ed4e585dfc46 (diff)
parentaf74efccf8d21e6151022b71f3cacd3fa83024ee (diff)
Merge branch 'rework-backend'
Diffstat (limited to 'dsa/DSALib/Commands/FileHandler.cs')
-rw-r--r--dsa/DSALib/Commands/FileHandler.cs32
1 files changed, 32 insertions, 0 deletions
diff --git a/dsa/DSALib/Commands/FileHandler.cs b/dsa/DSALib/Commands/FileHandler.cs
new file mode 100644
index 0000000..d117040
--- /dev/null
+++ b/dsa/DSALib/Commands/FileHandler.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Linq;
+using System.Net;
+using DSALib.DSA_Game;
+using DSALib.DSA_Game.Characters;
+using DSALib;
+using DSALib.Models.Dsa;
+
+namespace DSALib.Commands
+{
+ public class FileHandler
+ {
+ public static string AddChar(ulong id, string url)
+ {
+ if (url == string.Empty) throw new ArgumentException("Es wurde keine Datei angehängt");
+
+
+ if (!url.EndsWith(".xml")) throw new ArgumentException("Es wurde kein xml Held mitgeschickt");
+
+ using (var client = new WebClient())
+ {
+ client.DownloadFile(url, "helden\\" + url.Split("/").Last());
+ }
+
+ Dsa.Chars.Add(new Character("helden\\" + url.Split("/").Last()));
+ (Dsa.Chars.Last() as Character)?.Talente.Select(x => new Talent(x.Name, x.Probe, 0))
+ .Where(c => !Dsa.Talente.Exists(v => v.Name.Equals(c.Name))).ToList().ForEach(v => Dsa.Talente.Add(v));
+
+ return $"{url.Split("/").Last()} wurde erfolgreich gespeichert";
+ }
+ }
+} \ No newline at end of file