public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                client dbclient = new client();
                dbclient.client_fname    = model.client_fname;
                dbclient.client_lname    = model.client_lname;
                dbclient.client_address  = model.client_address;
                dbclient.client_company  = model.client_company;
                dbclient.client_mobile   = model.client_mobile;
                dbclient.client_nic      = model.client_nic;
                dbclient.client_username = model.Email;

                ClientsControllerManager ClientsControllerManager = new ClientsControllerManager();
                ClientsControllerManager.saveClient(dbclient);

                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Projects"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
 public ActionResult Create(client client)
 {
     try
     {
         if (ModelState.IsValid)
         {
             int flag = ClientsControllerManager.saveClient(client);
             if (flag == 1)
             {
                 return(RedirectToAction("Index", "Projects"));
             }
             else
             {
                 TempData["client_nic"] = "That NIC already registered. Use different one.";
             }
         }
         return(View());
     }
     catch (Exception)
     {
         return(RedirectToAction("Error", "Home"));
     }
 }