Ejemplo n.º 1
0
        public static async Task <string> UpdateProfile(int Id, RegisterFanForm form)
        {
            Serializer          serializer    = new Serializer();
            string              RequestBody   = serializer.Serialize(form);
            clsRequest          RequestObject = new clsRequest("-1", Id, RequestBody);
            HttpResponseMessage request       = await clsHttpClient.getClient().PutAsJsonAsync("users/fans/" + Id, RequestObject);

            if (request.IsSuccessStatusCode)
            {
                string response = request.Content.ReadAsStringAsync().Result;
                return(await Task.FromResult(response));
            }
            else
            {
                return(await Task.FromResult("Unexpected error ocurred"));
            }
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> RegisterFan(string inputUsername, string inputPassword, string inputConfirmPassword,
                                                     string inputName, string inputBirthday, int selectGender, int selectCountry, List <int> selectGenres, string profilePicture)
        {
            if (Sessions.isAuthenticated(Request, Session))
            {
                int sessionRol = Int32.Parse(Session["rol"].ToString());
                if (Sessions.isBand(sessionRol))
                {
                    return(RedirectToAction("Index", "Bands", new { area = "Bands", userId = Session["id"] }));
                }
                else if (Sessions.isFan(sessionRol))
                {
                    return(RedirectToAction("Index", "Fans", new { area = "Fans", userId = Session["id"] }));
                }
                else
                {
                    return(HttpNotFound());
                }
            }
            RegisterFanForm form = new RegisterFanForm();

            form.Username        = inputUsername;
            form.Password        = inputPassword;
            form.ConfirmPassword = inputConfirmPassword;
            form.Name            = inputName;
            form.Birthday        = inputBirthday;
            form.Gender          = selectGender;
            form.Country         = selectCountry;
            form.Genres          = selectGenres;
            form.Picture         = profilePicture;

            string response = await clsRegisterRequests.PostRegisterFanForm(form);

            System.Diagnostics.Debug.WriteLine(response);
            string ParsedMessage = ErrorParser.parse(response);

            if (!ParsedMessage.Equals(""))
            {
                ViewBag.Message = ParsedMessage;
                return(View("Index"));
            }
            ViewBag.Message = "We are glad to have you onboard!";

            return(RedirectToAction("Index", "Login"));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> UpdateProfile(string inputName, string inputBirthday, int selectGender, int selectCountry,
                                                       List <int> selectGenres, string profilePicture)
        {
            System.Diagnostics.Debug.WriteLine(selectGender);
            System.Diagnostics.Debug.WriteLine(selectCountry);
            if (Sessions.isAuthenticated(Request, Session))
            {
                RegisterFanForm form = new RegisterFanForm();
                form.Name     = inputName;
                form.Birthday = inputBirthday;
                form.Gender   = selectGender;
                form.Country  = selectCountry;
                form.Genres   = selectGenres;
                form.Picture  = profilePicture;

                string response = await clsFanRequests.UpdateProfile((int)Session["Id"], form);

                System.Diagnostics.Debug.WriteLine("form pytted", response);
                string ParsedMessage = ErrorParser.parse(response);
                if (!ParsedMessage.Equals(""))
                {
                    ViewBag.Message = ParsedMessage;
                }
                try {
                    Session["Name"] = form.Name;
                }
                catch (NullReferenceException)
                {
                    //Not logged in
                    ViewBag.Message = "Please log in first";
                    return(View("~/Views/Login/Index.cshtml"));
                }
                return(RedirectToAction("Edit", "Fans", new { area = "Fans", userId = Session["id"] }));
            }
            else
            {
                return(View("~/Views/Login/Index.cshtml"));
            }
        }