示例#1
0
        public ActionResult RegisterDoctor(RegisterDoctorModel model)
        {
            DoctorComposite doctor = new DoctorComposite
            {
                Doctor = new Doctor
                {
                    Surname    = model.Doctor.Surname,
                    Name       = model.Doctor.Name,
                    Patronymic = model.Doctor.Patronymic,
                    Area       = model.Doctor.Area,
                    Speciality = model.Doctor.Speciality
                },

                User = new User
                {
                    Login    = model.User.Login,
                    Password = model.User.Password
                }
            };

            DbWork db = new DbWork();

            db.RegisterDoctor(doctor);

            return(RedirectToAction("Index", "Home"));
        }
 private void button3_Click(object sender, EventArgs e)
 {
     FindControls(this, controls, ControlIdentifier);
     if (!FieldValidator.HasEmptyFields(controls.ToArray()))
     {
         if (PasswordBox.Text.Equals(ConfirmPasswordBox.Text))
         {
             RegisterDoctorModel doctorModel = CreateModel();
             doctorService.Save(doctorModel);
             MessageBox.Show("Successfully created medical staff profile");
             this.Hide();
             AdminHomeForm adminHome = new AdminHomeForm();
             adminHome.ShowDialog();
             this.Close();
         }
         else
         {
             MessageBox.Show("Password and Confirm Pasword mismatch");
         }
     }
     else
     {
         MessageBox.Show("Fill in all fileds");
     }
 }
        public async Task <IActionResult> RegisterDoctor([FromBody] RegisterDoctorModel model)
        {
            var veirfiedToken = await _registerService.RegisterDoctorAsync(_mapper.Map <AccountDoctorRegister>(model));

            return(Success(new TokenResult {
                Token = veirfiedToken
            }));
        }
示例#4
0
        public async Task <ActionResult> RegisterAsDoctor(RegisterDoctorModel 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.Doctor.ToString());
                        var doctor = new Doctor();
                        doctor.UserId       = user.Id;
                        doctor.LastName     = model.LastName;
                        doctor.FirstName    = model.FirstName;
                        doctor.UIN          = model.UIN;
                        doctor.MobileNumber = model.MobileNumber;
                        var isSave = _doctorService.SaveDoctor(doctor);
                        if (isSave > 0)
                        {
                            await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                            return(RedirectToAction("Index", "Home"));
                        }
                        else
                        {
                            await UserManager.DeleteAsync(user);
                        }
                    }
                    catch (Exception e)
                    {
                        string error = e.Message.ToString();
                        await UserManager.DeleteAsync(user);

                        ModelState.AddModelError(string.Empty, "Unable to crate doctor Profile.");
                        ModelState.AddModelError(string.Empty, "Make sure UIN number is correct. Already registered");
                    }
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
        private RegisterDoctorModel CreateModel()
        {
            RegisterDoctorModel model = new RegisterDoctorModel();

            model.Name           = NameTextBox.Text;
            model.Ucn            = UcnTextBox.Text;
            model.City           = CityComboBox.Text;
            model.Street         = StreetTextBox.Text;
            model.StreetNumber   = StreetNumberTextBox.Text;
            model.Ward           = WardComboBox.SelectedIndex;
            model.Specialization = SpecializationComboBox.SelectedIndex;
            model.Role           = RoleComboBox.SelectedIndex;
            model.Username       = UsernameTextBox.Text;
            model.Password       = PasswordBox.Text;
            model.Phone          = PhoneTextBox.Text;
            return(model);
        }
示例#6
0
 public ActionResult RegisterDoctor(RegisterDoctorModel model, HttpPostedFileBase uploadImage)
 {
     ViewBag.ClinicId = new SelectList(db.Clinics, "Id", "Name");
     if (ModelState.IsValid)
     {
         if (uploadImage != null)
         {
             byte[] imageData = null;
             using (var binaryReader = new BinaryReader(uploadImage.InputStream))
             {
                 imageData = binaryReader.ReadBytes(uploadImage.ContentLength);
             }
             ApplicationUser user         = db.Users.Find(User.Identity.GetUserId());
             DoctorInform    doctorInform = new DoctorInform
             {
                 Category       = model.Category,
                 Education      = model.Education,
                 Guardian       = model.Guardian,
                 Practiced      = false,
                 Specialization = model.Specialization,
                 ClinicId       = model.СlinicId,
                 Skills         = model.Skills,
                 Image          = imageData
             };
             db.DoctorInforms.Add(doctorInform);
             db.SaveChanges();
             user.DoctorInformId = doctorInform.Id;
             user.DoctorInform   = doctorInform;
             user.Name           = model.Name;
             user.Gender         = model.Gender;
             user.Bithday        = model.Birthday;
             db.SaveChanges();
             return(RedirectToAction("MyAccount"));
         }
         else
         {
             ModelState.AddModelError("", "Оберіть зображення");
         }
     }
     return(View(model));
 }
示例#7
0
        public ActionResult RegisterDoctor()
        {
            RegisterDoctorModel model = new RegisterDoctorModel();

            DbWork db = new DbWork();

            var areas = db.GetAreas();

            foreach (var st in areas)
            {
                model.Areas.Add(new AreaModel(st));
            }

            var specialities = db.GetSpecialities();

            foreach (var st in specialities)
            {
                model.Specialities.Add(new SpecialityModel(st));
            }

            return(View(model));
        }
        public void Save(RegisterDoctorModel doctorModel)
        {
            Doctor doctor = new Doctor
            {
                Name    = doctorModel.Name,
                Ucn     = doctorModel.Ucn,
                Address = new Address
                {
                    City         = doctorModel.City,
                    Street       = doctorModel.Street,
                    StreetNumber = doctorModel.StreetNumber
                },
                WardType           = (MedicalWardType)doctorModel.Ward,
                SpecializationType = (MedicalSpecializationType)doctorModel.Specialization,
                Username           = doctorModel.Username,
                Password           = doctorModel.Password,
                Role  = UserRoleType.Doctor,
                Phone = doctorModel.Phone
            };

            this.doctorRepository.Add(doctor);
        }