public static async System.Threading.Tasks.Task SaveUserAsync(UserModel model) { model.Id = Guid.NewGuid().ToString(); string clearPasswd = GeneralHelper.CreateRandomPassword(5); model.Password = HashHelper.GenerateSaltedHash(new SecureData(clearPasswd), new SecureData(model.UserName.ToLower())).ToString();; model.RemainingCount = 5; var client = new FireSharp.FirebaseClient(firebase.config); var get = client.Get(@"User/"); var rawdata = JsonConvert.DeserializeObject <Dictionary <string, UserModel> >(get.Body); List <UserModel> list = new List <UserModel>(); if (rawdata != null) { foreach (var item in rawdata) { list.Add(item.Value); } if (list.Where(q => q.UserName.Equals(model.UserName) || q.Email.Equals(model.Email)).ToList().Count != 0) { throw new Exception("hata"); } } await client.PushAsync(@"User/", model); await MailHelper.SendMail(model.Email, "Sayın " + model.UserName + " uygulamaya giriş için şifreniz : " + clearPasswd + "\n Kullanım hakkınız 5 dir."); }
public async Task <IActionResult> AddTrucker([FromBody] TruckerModel truckerModel) { var result = await _truckerServiceWebApp.AddTrucker(truckerModel); var client = new FireSharp.FirebaseClient(_firebaseConfig); var response = client.PushAsync("truckers/", result); return(Ok(result)); }