Beispiel #1
0
        public ActionResult Edit(EditDoctorVM edit)
        {
            if (!this.ModelState.IsValid)
            {
                return(View(edit));
            }

            UserService service = new UserService();
            User        user    = new User();

            user.Id        = edit.Id;
            user.Email     = edit.Email;
            user.Password  = edit.Password;
            user.Firstname = edit.Firstname;
            user.Lastname  = edit.Lastname;
            user.Phone     = edit.Phone;
            user.IsAdmin   = AuthenticationManager.LoggedUser.IsAdmin;

            service.Edit(user);

            if (edit.Specialization != null)
            {
                DoctorService serviceDoctor = new DoctorService();
                Doctor        doctor        = new Doctor();

                doctor.Specialization = edit.Specialization;
                doctor.Address        = edit.Address;
                doctor.UserId         = AuthenticationManager.LoggedUser.Id;

                serviceDoctor.Edit(doctor);
            }

            AuthenticationManager.Authenticate(AuthenticationManager.LoggedUser.Email, AuthenticationManager.LoggedUser.Password);
            return(RedirectToAction("Details", "Home"));
        }
Beispiel #2
0
        public ActionResult Edit()
        {
            User user = AuthenticationManager.LoggedUser;

            DoctorService service = new DoctorService();
            Doctor        doctor  = service.GetById(user.Id);

            EditDoctorVM edit = new EditDoctorVM();

            edit.Id        = user.Id;
            edit.Email     = user.Email;
            edit.Password  = user.Password;
            edit.Firstname = user.Firstname;
            edit.Lastname  = user.Lastname;
            edit.Phone     = user.Phone;
            edit.IsAdmin   = AuthenticationManager.LoggedUser.IsAdmin;

            if (doctor != null)
            {
                edit.Specialization = doctor.Specialization;
                edit.Address        = doctor.Address;
            }

            return(View(edit));
        }