public ActionResult Registrate(RegistartionViewModel registartionVm, HttpPostedFileBase image = null)
        {
            if (_authProvider.IsLoginUsed(registartionVm.Login))
            {
                TempData["errorMessage"] = "User with the same login already exists. Please, choose cooler one";

                return(View(registartionVm));
            }

            registartionVm.User.NickName = registartionVm.Login;

            if (!ModelState.IsValid)
            {
                return(View(registartionVm));
            }

            TempData["message"] =
                "Account was successfully created. Please check your email inbox for confiramtion mail";

            if (image != null)
            {
                registartionVm.User.MimeType = image.ContentType;
                registartionVm.User.Photo    = new byte[image.ContentLength];
                image.InputStream.Read(registartionVm.User.Photo, 0, image.ContentLength);
            }

            _userRepository.SaveUser(registartionVm.User);
            _authProvider.Registrate(registartionVm, Request.Url);

            return(RedirectToAction("Index"));
        }
        public ActionResult Registrate()
        {
            RegistartionViewModel registrationVm = new RegistartionViewModel
            {
                User = new User()
            };

            return(View(registrationVm));
        }
Example #3
0
        public async Task <bool> ProfileUpdateAsync(
            string email,
            string password,
            string name,
            string mobile)
        {
            try
            {
                RegistartionViewModel register = new RegistartionViewModel()
                {
                    email    = email,
                    password = password,
                    name     = name,
                    mobile   = mobile
                };

                string txt = this.serialize(register);

                var content = new StringContent(txt, Encoding.UTF8, "application/json");

                HttpClient client = new HttpClient();
                client.DefaultRequestHeaders.Add("Authorization", "Bearer " + Glo.Data.token);
                var resp = await client.PostAsync(Constants.API_URL + "/user/register", content);

                if (resp.StatusCode == HttpStatusCode.OK)
                {
                    //var cont= resp.Content.ReadAsStringAsync().ToString();

                    string cont = await resp.Content.ReadAsStringAsync();

                    //await DisplayAlert("Result", cont, "OK");
                    //cont = await resp.Content.ReadAsStringAsync().Result;

                    ResponseJSON res_json = (ResponseJSON)this.deserialize(cont, new ResponseJSON());

                    if (res_json.result_code == 100)
                    {
                        //await DisplayAlert("Result", cont, "OK");
                        return(true);
                    }

                    //Helpers.Utils.Msgbox(cont);

                    //await DisplayAlert("Hey", "Your record has been added", "Alright");
                }
            }
            catch (Exception e)
            {
                //throw new Exception(e.ToString());
            }

            return(false);
        }
        /// <summary>
        ///     Provides logic to registrate new user, sends confirmation mail if everything's done ok
        /// </summary>
        /// <param name="registrationModel"></param>
        /// <param name="uri"></param>
        public void Registrate(RegistartionViewModel registrationModel, Uri uri)
        {
            Guid key = _authProvider.RegistrateUser(registrationModel.User.NickName,
                                                    registrationModel.Password);

            StringBuilder mailBody = new StringBuilder();

            mailBody.Append("<html><head></head><body><div>Click link to confirm your account <a href=\"http://");
            mailBody.Append(uri.Authority);
            mailBody.Append("/Confirm/");
            mailBody.Append(registrationModel.User.NickName);
            mailBody.Append("/");
            mailBody.Append(key);
            mailBody.Append("\">here</a></body></html>");

            _mailSender.SendMail("Your new account", mailBody.ToString(), registrationModel.User.Email);
        }
Example #5
0
        public async Task <bool> SignupAsync(
            string email,
            string password,
            string name,
            string mobile)
        {
            try
            {
                RegistartionViewModel register = new RegistartionViewModel()
                {
                    email    = email,
                    password = password,
                    name     = name,
                    mobile   = mobile
                };

                string txt = this.serialize(register);

                //var xml = this.tiny_serialize(register);
                //await DisplayAlert("Result", xml, "OK");
                //Helpers.Utils.Msgbox(xml);

                //var aaa = await content.ReadAsStringAsync();
                //await DisplayAlert("Request", json, "OK");

                var content = new StringContent(txt, Encoding.UTF8, "application/json");
                //txt = await content.ReadAsStringAsync();

                HttpClient client = new HttpClient();
                var        resp   = await client.PostAsync(Constants.API_URL + "/user/register", content);

                //var resp = await client.GetAsync(Constants.API_URL+"/user/register");

                //System.Console.WriteLine("@Signupbtn: content="+content);
                //Helpers.Utils.Msgbox(""+result.StatusCode);

                if (resp.StatusCode == HttpStatusCode.OK)
                {
                    //var cont= resp.Content.ReadAsStringAsync().ToString();

                    string cont = await resp.Content.ReadAsStringAsync();

                    //await DisplayAlert("Result", cont, "OK");
                    //cont = await resp.Content.ReadAsStringAsync().Result;

                    ResponseJSON res_json = (ResponseJSON)this.deserialize(cont, new ResponseJSON());

                    if (res_json.result_code == 100)
                    {
                        //await DisplayAlert("Result", cont, "OK");
                        return(true);
                    }

                    //Helpers.Utils.Msgbox(cont);

                    //await DisplayAlert("Hey", "Your record has been added", "Alright");
                }
            }
            catch (Exception e)
            {
                //throw new Exception(e.ToString());
            }

            return(false);
        }