public async Task<ActionResult> Register(HirerRegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                // Initialize user object
                ApplicationUser user = new ApplicationUser() { UserName = model.Email.ToLower().Trim(), LoweredUserName = model.Email.Trim().ToLower(), ApplicationId = GetApplicationID(), Email = model.Email.Trim(), LoweredEmail = model.Email.Trim().ToLower() };

                MacheteContext Db = DatabaseFactory.Get();

                // Create user
                IdentityResult result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    // Retrieve newly created user record to retrieve userId
                    ApplicationUser newUser = await UserManager.FindAsync(user.UserName, model.Password);
                    if (newUser != null)
                    {
                        result = await UserManager.AddToRoleAsync(newUser.Id, "Hirer");
                        if (result.Succeeded)
                        {
                            // Sign in user
                            await SignInAsync(user, isPersistent: false);

                            // Redirect to hire worker page
                            return RedirectToAction("/", "HirerWorkOrder");
                        }
                        else
                        {
                            AddErrors(result);
                        }

                    }
                    else // new user couldn't be found
                    {
                        // TODO: provide error reporting
                    }

                }
                else // create new user failed
                {
                    // Message the user
                    AddErrors(result);
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
 public ActionResult Register()
 {
     HirerRegisterViewModel model = new HirerRegisterViewModel();
     return View(model);
 }