コード例 #1
0
        private void CreateUser(String email, String password, TravelAgencyService service, Action createUser)
        {
            List <String> errorList = new List <string>(1);
            bool          isSuccess = false;

            // Attempt to register the user
            if (WebDataHelper.CreateAccount(email, password, errorList))
            {
                try
                {
                    createUser();
                    service.Save();
                    WebSecurity.Login(email, password);
                    isSuccess = true;
                }
                catch (Exception ex)
                {
                    HandleRegistrationError(email, ex);
                }
            }
            else
            {
                ModelState.AddModelError("", "E-mail is already in use.");
            }
            // Warning: Redirect to URL throws special exception which must not be handled.
            // Whne it is handled in above try then the newly created account is deleted.
            if (isSuccess)
            {
                RedirectHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
            }
        }
コード例 #2
0
        public override async void ViewDidLoad()
        {
            var localData = DataManager.GetTopInfluencers();

            var client = new WebDataHelper <IEnumerable <Influencer> >();
            var list   = await client.GetData("http://50.19.213.136:8080/skills-devdom/api/influencer/top/general.json");


            var firstSection = new Section("Coolest Dev")
            {
                new BadgeElement(UIImage.FromBundle("me.jpg"), "Claudio Sanchez"),
            };

            var section = new Section("Top 20");

            Root.Add(firstSection);
            Root.Add(section);

            foreach (var influencer in list)
            {
                var image = await ImageHelper.LoadImage(influencer.picture);

                var element = new BadgeElement(image, string.Format("[{0}] {1}", influencer.position, influencer.fullName));
                section.Add(element);
            }
        }
コード例 #3
0
        private bool CreateAccount(RegistrationModel model)
        {
            List <String> erroList = new List <String>(1);
            var           res      = WebDataHelper.CreateAccount(model.RegisterData.Email, model.RegisterData.Password, erroList);

            erroList.ForEach(i => ModelState.AddModelError(String.Empty, i));
            return(res);
        }
コード例 #4
0
        private bool CheckPassword(ChangePasswordData cd, tKlient client)
        {
            List <String> errorList = new List <String>(2);
            var           res       = WebDataHelper.CheckPasswords(cd.OldPassword, cd.NewPassword, cd.NewPassword2, client, errorList);

            errorList.ForEach(e => ModelState.AddModelError("", e));
            return(res);
        }
コード例 #5
0
 private bool ChangePassword(String oldPassword, string newPassword, int clientId)
 {
     if (ModelState.IsValid)
     {
         List <String> errorList = new List <String>(2);
         var           res       = WebDataHelper.ChangePassword(User.Identity.Name, oldPassword, newPassword, clientId, errorList);
         errorList.ForEach(e => ModelState.AddModelError("", e));
         return(res);
     }
     return(false);
 }
コード例 #6
0
 private void HandleRegistrationError(RegistrationModel model, Exception ex)
 {
     try
     {
         WebDataHelper.DeleteUser(model.RegisterData.Email);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
     }
     ModelState.AddModelError("", ex.Message);
 }
コード例 #7
0
        public ActionResult Login(LoginModel model, String returnUrl)
        {
            ViewBag.ReturnUrl = returnUrl;
            if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
            {
                WebDataHelper.AddUserToRole(model.UserName);
                return(RedirectToLocal(returnUrl));
            }
            else
            {
                ViewBag.LoginMessage = "Login failed.";
            }

            return(View(model));
        }
コード例 #8
0
ファイル: Login.aspx.cs プロジェクト: jns300/TravelAgency.NET
 protected void LogIn(object sender, EventArgs e)
 {
     if (IsValid)
     {
         if (WebSecurity.Login(LoginTextBox.Text, Password.Text, persistCookie: RememberMe.Checked))
         {
             WebDataHelper.AddUserToRole(LoginTextBox.Text);
             RedirectHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
         }
         else
         {
             ModelState.AddModelError("", "Login failed.");
         }
     }
 }
コード例 #9
0
        public async Task LoadAsync()
        {
            try
            {
                ProgramUrl = await WebDataHelper.GetProgramLink();
            }
            catch (Exception)
            {
                ProgramName = programName + "\nError al mostrar la imágen del programa";
            }

            try
            {
                ProgramName = await WebDataHelper.GetProgramName();
            }
            catch (Exception)
            {
                ProgramName = programName + "Error al mostrar el nombre del programa";
            }
        }
コード例 #10
0
 async Task ExecuteLoadBanner()
 {
     Banner = (await WebDataHelper.GetBannerPrograma()).Trim();
 }
コード例 #11
0
 async Task ExecuteLoadNombre()
 {
     Nombre = "...";
     Nombre = (await WebDataHelper.GetNombrePrograma()).Trim();
 }