Esempio n. 1
0
        public ActionResult Register(int ? id)
        {
            var model = new RegisterViewModel() { };
            if (id == 1)
            {
                model.Role = "User";
            }
            if (id == 2)
            {
                model.Role = " Company";
            }

            return View(model);
        }
Esempio n. 2
0
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return View(model);
            }

            try
            {
                if(model.Role == "User")
                {
                    model.Email = "*User*" + model.Email;
                }
                else
                {
                    model.Email = "*Comp*" + model.Email;
                }
                
                await WebApiService.Instance.PostAsync("/api/Account/Register", model);

                if (model.Role == "User")
                {
                    return RedirectToAction("Index", "Company");
                }
                else
                {
                    return RedirectToAction("Create", "Company", routeValues:new {userName = model.Email});
                }

               
            }
            catch (ApiException ex)
            {
                //No 200 OK result, what went wrong?
                HandleBadRequest(ex);

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

                throw;
            }
        }