Esempio n. 1
0
        public ActionResult RegisterPacient(RegisterPatientModel model)
        {
            PatientComposite patient = new PatientComposite
            {
                Patient = new Patient
                {
                    Surname    = model.Patient.Surname,
                    Name       = model.Patient.Name,
                    Patronymic = model.Patient.Patronymic,
                    Street     = model.Patient.Street,
                    House      = model.Patient.House,
                    Room       = model.Patient.Room
                },
                User = new User
                {
                    Login    = model.User.Login,
                    Password = model.User.Password
                }
            };

            DbWork db = new DbWork();

            db.RegistryPatient(patient);

            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 2
0
        public ActionResult RegisterPacient()
        {
            RegisterPatientModel model = new RegisterPatientModel();

            DbWork db = new DbWork();

            var streets = db.GetStreets();

            foreach (var st in streets)
            {
                model.Streets.Add(new StreetModel(st));
            }

            return(View(model));
        }
Esempio n. 3
0
        public ActionResult RegisterPatient(RegisterPatientModel model)
        {
            if (ModelState.IsValid)
            {
                ApplicationUser user          = db.Users.Find(User.Identity.GetUserId());;
                PatientInform   patientInform = new PatientInform {
                    Allergy = model.Allergy, BloodGroup = model.BloodGroup, Diabetes = model.Diabetes, Activity = model.Activity, Adress = model.Adress, Infectious_diseases = model.Infectious_diseases, Operations = model.Operations
                };
                db.PatientInforms.Add(patientInform);
                db.SaveChanges();
                user.PatientInformId = patientInform.Id;
                user.Name            = model.Name;
                user.Gender          = model.Gender;
                user.Bithday         = model.Birthday;

                db.SaveChanges();
                return(RedirectToAction("MyAccount"));
            }
            return(View(model));
        }
Esempio n. 4
0
        public async Task <ActionResult> RegisterAsPatient(RegisterPatientModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    try
                    {
                        UserManager.AddToRole(user.Id, UserRoles.Patient.ToString());
                        var patient = new Patient();
                        patient.UserId = user.Id;

                        var isSave = _patientService.SavePatient(patient);
                        if (isSave > 0)
                        {
                            await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                            return(RedirectToAction("Index", "Home"));
                        }
                        else
                        {
                            await UserManager.DeleteAsync(user);
                        }
                    }
                    catch (Exception e)
                    {
                        ModelState.AddModelError(string.Empty, "Unable to crate patient Profile.");
                    }
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
        public async Task <IdentityResult> RegisterPatient(RegisterPatientModel model)
        {
            Patient user = new Patient()
            {
                Email           = model.Email,
                SecurityStamp   = Guid.NewGuid().ToString(),
                UserName        = model.UserName,
                FirstName       = model.FirstName,
                LastName        = model.LastName,
                StreetAddress   = model.StreetAddress,
                City            = model.City,
                State           = model.State,
                Zipcode         = model.Zipcode,
                PhoneNumber     = model.PhoneNumber,
                InsuranceName   = model.InsuranceName,
                InsuranceNumber = model.InsuranceNumber
            };

            var result = await _userManager.CreateAsync(user, model.Password);

            await _userManager.AddToRoleAsync(user, "Patient");

            return(result);
        }
        public async Task <IActionResult> RegisterPatient([FromBody] RegisterPatientModel model)
        {
            var userExists = await _userService.FindUserByName(model.UserName);

            if (userExists != null)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, new { Status = "Error", Message = "User already exists!" }));
            }

            else
            {
                var result = await _accountLogic.RegisterPatient(model);

                if (result.Succeeded)
                {
                    return(Ok(new { Status = "Success", Message = "User created successfully!" }));
                }

                else
                {
                    return(StatusCode(StatusCodes.Status500InternalServerError, new { Status = "Error", Message = "User creation failed! Please check user details and try again." }));
                }
            }
        }