Пример #1
0
        // GET: Account
        public ActionResult Account()
        {
            if (Session["authtoken"] == null)
            {
                return(RedirectToAction("Login", "Auth", new { returnUrl = HttpContext.Request.Url.AbsolutePath }));
            }
            Domain.Entities.Doctor doctor = (Domain.Entities.Doctor)Session["user"];
            AccountVM accountVM           = new AccountVM
            {
                username = doctor.username,
                email    = doctor.email
            };

            return(View(accountVM));
        }
Пример #2
0
        public async Task <ActionResult> RegisterDoctor(CustomerRegisterDoctor model, HttpPostedFileBase image)
        {
            string pic  = System.IO.Path.GetFileName(image.FileName);
            string path = System.IO.Path.Combine(Server.MapPath("~/Images"), pic);

            // file is uploaded
            image.SaveAs(path);

            if (ModelState.IsValid)
            {
                var role = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole();
                var user = new Domain.Entities.Doctor {
                    UserName  = model.Email,
                    Email     = model.Email, cin = model.cin, firstName = model.firstName,
                    lastName  = model.lastName, PhoneNumber = model.PhoneNumber,
                    gender    = model.gender, Address = model.Address,
                    RoleUser  = "******",
                    imagePath = pic,
                };


                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("DoctorProfile", "Calender"));
                }
                AddErrors(result);
            }


            // If we got this far, something failed, redisplay form

            return(View(model));
        }