/* ========================== change mobile ========================= */
        public ActionResult ChangeMobile(ChangePersonalInfo model)
        {
            try
            {
                firebaseClient = new FireSharp.FirebaseClient(firebaseConfig);
                Debug.WriteLine(model.UserID);
                Debug.WriteLine(model.UserType);

                if (model.UserType == "donor")
                {
                    FirebaseResponse response = firebaseClient.Get("Donator/" + model.UserID);
                    Donator          data     = JsonConvert.DeserializeObject <Donator>(response.Body);
                    data.Mobile = model.Mobile;

                    SetResponse setResponse = firebaseClient.Set("Donator/" + data._id, data);

                    ModelState.AddModelError(string.Empty, "Mobile number changed successfully");
                    Debug.WriteLine("Mobile number changed successfully");
                }
                else if (model.UserType == "volunteer")
                {
                    FirebaseResponse response = firebaseClient.Get("Volunteer/" + model.UserID);
                    Volunteer        data     = JsonConvert.DeserializeObject <Volunteer>(response.Body);
                    data.Mobile = model.Mobile;

                    SetResponse setResponse = firebaseClient.Set("Volunteer/" + data._id, data);

                    ModelState.AddModelError(string.Empty, "Mobile number changed successfully");
                    Debug.WriteLine("Mobile number changed successfully");
                }
            }catch (Exception ex)
            {
                Debug.WriteLine("Exception from change mobile " + ex);
            }

            return(RedirectToAction("/PersonalInfo"));
        }
        private bool SetPersonalInfo(ChangePersonalInfo personalInfo)
        {
            var isMerchant = UserIsMerchant();

            var edited = this._virtualOfficeService.UpdatePersonalInfo(personalInfo.Id, personalInfo.Email, personalInfo.Phone, isMerchant);

            return edited;
        }
        public ActionResult PersonalInfo(ChangePersonalInfo personalInfoModel)
        {
            try
            {
                if (!ModelState.IsValid)
                    return RedirectToAction("PersonalInfo", new { success = false });

                personalInfoModel.Id = GetLoggedUserId();

                var edited = SetPersonalInfo(personalInfoModel);

                if (!edited)
                    throw new Exception();

                return RedirectToAction("PersonalInfo", new { success = true, message = "Your inforfation have been changed successfully!" });
            }
            catch (Exception exception)
            {
                return RedirectToAction("PersonalInfo", new { success = false, message = "There were errors while proccesing your request.Try again later please." });
            }
        }
        /* ========================= change password ======================== */
        public async Task <ActionResult> ChangePassword(ChangePersonalInfo model)
        {
            try
            {
                firebaseClient = new FireSharp.FirebaseClient(firebaseConfig);
                Debug.WriteLine(model.UserID);
                Debug.WriteLine(model.UserType);


                if (model.UserType == "donor")
                {
                    Donator donor = (Donator)Session["donator"];

                    if (model.Password.Equals(model.ConfirmPassword))
                    {
                        FirebaseResponse response = firebaseClient.Get("Donator/" + model.UserID);
                        Donator          data     = JsonConvert.DeserializeObject <Donator>(response.Body);
                        data.Password = model.Password;
                        Debug.WriteLine(data.Email);

                        // delet auth first
                        UserRecord userRecord = await FirebaseAuth.DefaultInstance.GetUserByEmailAsync(data.Email);

                        Debug.WriteLine(userRecord);
                        //await FirebaseAuth.DefaultInstance.DeleteUserAsync(userRecord.Uid);

                        // set again auth
                        var auth = new FirebaseAuthProvider(new FirebaseConfig(ApiKey));
                        var a    = await auth.CreateUserWithEmailAndPasswordAsync(data.Email, data.Password, data.Name);

                        SetResponse setResponse = firebaseClient.Set("Donator/" + data._id, data);

                        ModelState.AddModelError(string.Empty, "Password changed successfully");
                        Debug.WriteLine("Password changed successfully");
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, "Password did not match");
                    }
                }
                else if (model.UserType == "volunteer")
                {
                    Volunteer volunteer = (Volunteer)Session["volunteer"];
                    if (model.Password.Equals(model.ConfirmPassword))
                    {
                        FirebaseResponse response = firebaseClient.Get("Volunteer/" + model.UserID);
                        Volunteer        data     = JsonConvert.DeserializeObject <Volunteer>(response.Body);
                        data.Password = model.Password;

                        SetResponse setResponse = firebaseClient.Set("Volunteer/" + data._id, data);

                        ModelState.AddModelError(string.Empty, "Password changed successfully");
                        Debug.WriteLine("Password changed successfully");
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, "Password did not match");
                    }
                }
            }catch (Exception ex)
            {
                Debug.WriteLine("Exception from pass change " + ex);
            }

            return(RedirectToAction("/PersonalInfo"));
        }