public async Task<ActionResult> Create(DoctorViewModel DoctorViewModel)
        {
            if (ModelState.IsValid)
            {
                var UserManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(context));
                var RoleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(context));
                var user = new ApplicationUser() { UserName = DoctorViewModel.Email };
                var result = await UserManager.CreateAsync(user, DoctorViewModel.Password);
                string roleName = "Doctor";
                IdentityResult roleResult;
                if (!RoleManager.RoleExists(roleName))
                {
                    roleResult = RoleManager.Create(new IdentityRole(roleName));
                }
                try
                {
                    var findUser = UserManager.FindByName(DoctorViewModel.Email);
                    UserManager.AddToRole(findUser.Id, "Doctor");
                    context.SaveChanges();
                }
                catch
                {
                    throw;
                }
                Doctor_Detail doctor = MapDoctor(DoctorViewModel);
                db.Doctor_Details.Add(doctor);
                await db.SaveChangesAsync();
                return RedirectToAction("Index");
            }

            return View(DoctorViewModel);
        }
 private static Doctor_Detail MapDoctor(DoctorViewModel DoctorViewModel)
 {
     var doctor = new Doctor_Detail();
     doctor.address = DoctorViewModel.address;
     doctor.cellno = DoctorViewModel.cellno;
     doctor.first_name = DoctorViewModel.first_name;
     doctor.med_practice_no = DoctorViewModel.med_practice_no;
     doctor.post_code = DoctorViewModel.post_code;
     doctor.specialization = DoctorViewModel.specialization;
     doctor.surname = DoctorViewModel.surname;
     doctor.telno = DoctorViewModel.telno;
     doctor.Email = DoctorViewModel.Email;
     return doctor;
 }