Beispiel #1
0
        public async Task <IActionResult> DoctorRegistration(DoctorFormViewModel model)
        {
            Doctor doctorr = new Doctor()
            {
                Address     = model.doctor.Address,
                Phone       = model.doctor.Phone,
                Name        = model.doctor.Name,
                IsAvailable = true,
            };
            var iss = model.doctor.Id;

            _context.Doctors.Add(doctorr);


            await _context.SaveChangesAsync();

            var doctorId = doctorr.Id;

            foreach (var id in model.SelectedeSepcializationId)
            {
                _context.DoctorSpecializations.Add(new DoctorSpecialization
                {
                    SpecializationId = id,
                    DoctorId         = doctorId
                });
            }
            await _context.SaveChangesAsync();



            return(RedirectToAction("Index", "Home"));
        }
Beispiel #2
0
        public async Task <IActionResult> DoctorRegistration(DoctorFormViewModel model)
        {
            var user = new ApplicationUser()
            {
                UserName = model.registerViewModel.Email,
                Email    = model.registerViewModel.Email,
                IsActive = true
            };
            var result = await userManager.CreateAsync(user, model.registerViewModel.Password);

            if (result.Succeeded)
            {
                var doctor = new Doctor()
                {
                    Address          = model.doctor.Address,
                    Phone            = model.doctor.Phone,
                    SpecializationId = model.doctor.SpecializationId,
                    Name             = model.doctor.Name,
                    IsAvailable      = true,
                };
                _unitOfWork.doctorRepository.Add(doctor);
                _unitOfWork.Complete();
                return(RedirectToAction("Index", "Home"));
            }
            return(View());
        }
        public ActionResult RegisterDoctor()
        {
            var viewModel = new DoctorFormViewModel();
            var cities    = _unitofWork.Cities.GetCities().Count();

            viewModel.Specializations = _unitofWork.Specializations.GetSpecializations();
            return(View("DoctorForm", viewModel));
        }
Beispiel #4
0
        public ActionResult RegisterDoctor()
        {
            var viewModel = new DoctorFormViewModel()
            {
                Specializations = _unitOfWork.Specializations.GetSpecializations()
                                  // Doctors = _doctorRepository.GetDectors()
            };

            return(View("DoctorForm", viewModel));
        }
Beispiel #5
0
        //New Doctor Action
        public ActionResult New()
        {
            var doctor    = new Doctor();
            var viewModel = new DoctorFormViewModel
            {
                Doctor = doctor
            };

            return(View("DoctorForm", viewModel));
        }
        public ActionResult New()
        {
            var specialistAreas = _context.SpecialListAreas.ToList();
            var viewModel       = new DoctorFormViewModel
            {
                Doctors          = new Doctor(),
                SpecialListAreas = specialistAreas
            };

            return(View("DoctorForm", viewModel));
        }
Beispiel #7
0
        public ActionResult DoctorRegister()
        {
            var doctorVm = new DoctorFormViewModel {
                Doctor       = new Doctor(),
                Specialities = db.Specialities.ToList(),
                Governorates = db.Governorates.ToList(),
                Cities       = db.Cities.ToList()
            };

            return(View(doctorVm));
        }
Beispiel #8
0
        public async Task <IActionResult> Edit(DoctorFormViewModel model)
        {
            var user = _unitOfWork.doctorRepository.GetDoctorById(model.doctor.Id);

            user.Name             = model.doctor.Name;
            user.Phone            = model.doctor.Phone;
            user.Address          = model.doctor.Address;
            user.SpecializationId = model.doctor.SpecializationId;

            _unitOfWork.Complete();

            return(RedirectToAction("Index", "Doctor"));
        }
        public ActionResult New()
        {
            var doctor = new Doctor();

            doctor.DocId = GenerateUniqueID();

            var viewModel = new DoctorFormViewModel
            {
                Doctor = doctor,
                Degree = _degrees.GetRecords,
                specs  = _specs.GetRecords,
                Gender = _genders.GetRecords,
            };

            return(View("DoctorForm", viewModel));
        }
Beispiel #10
0
        public async Task <IActionResult> RegisterDoctor(DoctorFormViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser()
                {
                    Name     = viewModel.RegisterViewModel.Name,
                    UserName = viewModel.RegisterViewModel.Email,
                    Email    = viewModel.RegisterViewModel.Email,
                    IsActive = true,
                    UserType = UserTypes.Doctor
                };
                var result = await userManager.CreateAsync(user, viewModel.RegisterViewModel.Password);

                if (result.Succeeded)
                {
                    await userManager.AddToRoleAsync(user, RoleName.DoctorRoleName);


                    Doctor doctor = new Doctor()
                    {
                        Name             = viewModel.Name,
                        Phone            = viewModel.Phone,
                        Address          = viewModel.Address,
                        IsAvailable      = true,
                        SpecializationId = viewModel.Specialization,
                        PhysicianId      = user.Id,
                    };
                    await userManager.AddClaimAsync(user, new Claim(ClaimTypes.GivenName, doctor.Name));

                    //Mapper.Map<DoctorFormViewModel, Doctor>(model, doctor);

                    _unitOfWork.Doctors.Add(doctor);
                    _unitOfWork.Complete();
                    return(RedirectToAction("Index", "Doctors"));
                }
                viewModel.Specializations = _unitOfWork.Specializations.GetSpecializations();

                ModelState.AddModelError("", "Something failed.");
                return(View("DoctorForm", viewModel));
            }

            viewModel.Specializations = _unitOfWork.Specializations.GetSpecializations();

            // If we got this far, something failed, redisplay form
            return(View("DoctorForm", viewModel));
        }
        public ActionResult Edit(int id)
        {
            var doctor = _context.Doctors.SingleOrDefault(c => c.Id == id);

            if (doctor == null)
            {
                return(HttpNotFound());
            }
            var viewModel = new DoctorFormViewModel
            {
                Doctors          = doctor,
                SpecialListAreas = _context.SpecialListAreas.ToList()
            };


            return(View("DoctorForm", viewModel));
        }
        public ActionResult Edit(string id)
        {
            var doctor = _context.LoadRecordByIdProperity <Doctor>(_table, id);

            if (doctor == null)
            {
                return(HttpNotFound());
            }
            var viewModel = new DoctorFormViewModel
            {
                Doctor = doctor,
                Gender = _genders.GetRecords,
                Degree = _degrees.GetRecords,
                specs  = _specs.GetRecords
            };

            return(View("DoctorForm", viewModel));
        }
        public ActionResult Edit(DoctorFormViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Specializations = _unitOfWork.Specializations.GetSpecializations();
                return(View(model));
            }
            var docInDb = _unitOfWork.Doctors.GetDoctor(model.Id);

            docInDb.Id               = model.Id;
            docInDb.IsAvailable      = model.IsAvailable;
            docInDb.Name             = model.Name;
            docInDb.Phone            = model.Phone;
            docInDb.Address          = model.Address;
            docInDb.SpecializationId = model.Specialization;
            _unitOfWork.Complete();
            return(RedirectToAction("DoctorProfile"));
        }
        public async Task <ActionResult> RegisterDoctor(DoctorFormViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.RegisterViewModel.Email, Email = model.RegisterViewModel.Email, Sex = model.RegisterViewModel.Sex
                };
                var result = await UserManager.CreateAsync(user, model.RegisterViewModel.Password);

                if (result.Succeeded)
                {
                    UserManager.AddToRole(user.Id, RoleName.Doctor);

                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    Doctor doctor = new Doctor
                    {
                        Name             = model.Name,
                        SpecializationId = model.Specialization,
                        Address          = model.Address,
                        IsAvailable      = model.IsAvailable,
                        Phone            = model.Phone,
                        PhysicianId      = user.Id
                    };
                    _unitofWork.Doctors.Add(doctor);
                    _unitofWork.Complete();
                    // For more information on how to enable account confirmation and password reset please visit https://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>");

                    UserManager.AddClaim(user.Id, new Claim(ClaimTypes.GivenName, doctor.Name));

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }
            model.Specializations = _unitofWork.Specializations.GetSpecializations();
            // If we got this far, something failed, redisplay form
            return(View("DoctorForm", model));
        }
Beispiel #15
0
        public async Task <IActionResult> DoctorRegistration()
        {
            var specializations = _unitOfWork.specializationRepository.GetSpecializations();
            var model           = new DoctorFormViewModel();

            foreach (var Specialization in specializations)
            {
                model.SpecializationList.Add(new SelectListItem()
                {
                    Value = Specialization.SpecializationId.ToString(),

                    Text = Specialization.Name
                }

                                             );
            }


            return(View(model));
        }
Beispiel #16
0
        //only for admin
        public async Task <IActionResult> Edit(int id)
        {
            var user            = _unitOfWork.doctorRepository.GetDoctorById(id);
            var specializations = _unitOfWork.specializationRepository.GetSpecializations();
            var model           = new DoctorFormViewModel
            {
                doctor = user
            };

            foreach (var item in specializations)
            {
                model.SpecializationList.Add(new SelectListItem()
                {
                    Value = item.SpecializationId.ToString(),
                    Text  = item.Name
                });
            }

            return(View(model));
        }
        public ActionResult Edit(DoctorFormViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                viewModel.Specializations = _unitOfWork.Specializations.GetSpecializations();
                return(View(viewModel));
            }

            var doctorInDb = _unitOfWork.Doctors.GetDoctor(viewModel.Id);

            doctorInDb.Id               = viewModel.Id;
            doctorInDb.Name             = viewModel.Name;
            doctorInDb.Phone            = viewModel.Phone;
            doctorInDb.Address          = viewModel.Address;
            doctorInDb.IsAvailable      = viewModel.IsAvailable;
            doctorInDb.SpecializationId = viewModel.Specialization;

            _unitOfWork.Complete();

            return(RedirectToAction("Details", new { id = viewModel.Id }));
        }
        public ActionResult Edit(int id)
        {
            var doctor = _unitOfWork.Doctors.GetDoctor(id);

            if (doctor == null)
            {
                return(StatusCode(404));
            }
            var viewModel = new DoctorFormViewModel()
            {
                Id              = doctor.Id,
                Name            = doctor.Name,
                Phone           = doctor.Phone,
                Address         = doctor.Address,
                IsAvailable     = doctor.IsAvailable,
                Specialization  = doctor.SpecializationId,
                Specializations = _unitOfWork.Specializations.GetSpecializations()
            };

            return(View(viewModel));
        }
        public ActionResult Save(Doctor doctor)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new DoctorFormViewModel
                {
                    Doctor = doctor,
                    Gender = _genders.GetRecords,
                    Degree = _degrees.GetRecords,
                    specs  = _specs.GetRecords
                };

                return(View("DoctorForm", viewModel));
            }

            if (doctor.Id == Guid.Empty)
            {
                _context.InsertRecord(_table, doctor);
            }

            else
            {
                var DoctorInDb = _context.LoadRecordByIdProperity <Doctor>(_table, doctor.DocId);
                DoctorInDb.DocId        = doctor.DocId;
                DoctorInDb.Name         = doctor.Name;
                DoctorInDb.Address      = doctor.Address;
                DoctorInDb.Salary       = doctor.Salary;
                DoctorInDb.NationalId   = doctor.NationalId;
                DoctorInDb.Phone        = doctor.Phone;
                DoctorInDb.BithDate     = doctor.BithDate;
                DoctorInDb.EmailAddress = doctor.EmailAddress;
                DoctorInDb.SpecId       = doctor.SpecId;
                DoctorInDb.GendreId     = doctor.GendreId;
                DoctorInDb.DegreeId     = doctor.DegreeId;

                _context.UPsertRecordByObjectId(_table, doctor.Id, doctor);
            }

            return(RedirectToAction("Index", "Doctors"));
        }
Beispiel #20
0
        public async Task <ActionResult> RegisterDoctor(DoctorFormViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser()
                {
                    UserName = viewModel.RegisterViewModel.Email,
                    Email    = viewModel.RegisterViewModel.Email,
                    IsActive = true
                };
                var result = await UserManager.CreateAsync(user, viewModel.RegisterViewModel.Password);


                if (result.Succeeded)
                {
                    UserManager.AddToRole(user.Id, RoleName.DoctorRoleName);


                    Doctor doctor = new Doctor()
                    {
                        Name             = viewModel.Name,
                        Phone            = viewModel.Phone,
                        Address          = viewModel.Address,
                        IsAvailable      = true,
                        SpecializationId = viewModel.Specialization,
                        PhysicianId      = user.Id
                    };
                    UserManager.AddClaim(user.Id, new Claim(ClaimTypes.GivenName, doctor.Name));
                    //Mapper.Map<DoctorFormViewModel, Doctor>(model, doctor);
                    _unitOfWork.Doctors.Add(doctor);
                    _unitOfWork.Complete();
                    return(RedirectToAction("Index", "Doctors"));
                }

                this.AddErrors(result);
            }

            viewModel.Specializations = _unitOfWork.Specialization.GetSpecializations();
            return(View("DoctorForm", viewModel));
        }
Beispiel #21
0
        public async Task <ActionResult> DoctorRegister(DoctorFormViewModel model, int cityId, HttpPostedFileBase upload)
        {
            //model.registerViewModel.Name = model.Doctor.Name;
            if (!ModelState.IsValid)
            {
                //model.registerViewModel.Name = model.Doctor.Name;

                var user = new ApplicationUser()
                {
                    UserName = model.registerViewModel.Email,
                    Email    = model.registerViewModel.Email,
                    Name     = model.registerViewModel.Name
                };
                var result = await UserManager.CreateAsync(user, model.registerViewModel.Password);

                if (result.Succeeded)
                {
                    var roleStore   = new RoleStore <IdentityRole>(new ApplicationDbContext());
                    var roleManager = new RoleManager <IdentityRole>(roleStore);
                    await roleManager.CreateAsync(new IdentityRole(RoleName.Doctor));

                    await UserManager.AddToRoleAsync(user.Id, RoleName.Doctor);

                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);


                    string path = Path.Combine(Server.MapPath("~/Uploads"), upload.FileName);
                    upload.SaveAs(path);
                    model.Doctor.DoctorImage = upload.FileName;


                    Doctor doctor = new Doctor()
                    {
                        Name              = model.registerViewModel.Name,
                        Phone             = model.Doctor.Phone,
                        DoctorImage       = model.Doctor.DoctorImage,
                        Address           = model.Doctor.Address,
                        Gender            = model.Doctor.Gender,
                        DoctorEmail       = model.registerViewModel.Email,
                        SpecialityId      = model.Doctor.SpecialityId,
                        DoctorInformation = model.Doctor.DoctorInformation,
                        Price             = model.Doctor.Price,
                        GovernorateId     = model.GovernorateId,
                        CityId            = cityId,
                        PhysicianId       = user.Id
                    };

                    UserManager.AddClaim(user.Id, new Claim(ClaimTypes.GivenName, user.Name));
                    db.Doctors.Add(doctor);
                    db.SaveChanges();

                    // For more information on how to enable account confirmation and password reset please visit https://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("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Beispiel #22
0
        //Edit Doctor
        public ActionResult Edit(Guid id)
        {
            var doctor = _context.Doctors.SingleOrDefault(d => d.Id == id);

            if (doctor == null)
            {
                return(HttpNotFound());
            }
            else
            {
                var availability = _context.Availability
                                   .Where(a => a.DoctorId == doctor.Id).ToList();

                var days = new Dictionary <string, bool>();

                foreach (Availability daysAvailable in availability)
                {
                    if (daysAvailable.Monday)
                    {
                        days.Add("Monday", true);
                    }
                    else
                    {
                        days.Add("Monday", false);
                    }
                    if (daysAvailable.Tuesday)
                    {
                        days.Add("Tuesday", true);
                    }
                    else
                    {
                        days.Add("Tuesday", false);
                    }
                    if (daysAvailable.Wednesday)
                    {
                        days.Add("Wednesday", true);
                    }
                    else
                    {
                        days.Add("Wednesday", false);
                    }
                    if (daysAvailable.Thursday)
                    {
                        days.Add("Thursday", true);
                    }
                    else
                    {
                        days.Add("Thursday", false);
                    }
                    if (daysAvailable.Friday)
                    {
                        days.Add("Friday", true);
                    }
                    else
                    {
                        days.Add("Friday", false);
                    }
                    if (daysAvailable.Saturday)
                    {
                        days.Add("Saturday", true);
                    }
                    else
                    {
                        days.Add("Saturday", false);
                    }
                    if (daysAvailable.Sunday)
                    {
                        days.Add("Sunday", true);
                    }
                    else
                    {
                        days.Add("Sunday", false);
                    }
                }

                doctor.DaysAvailable = days;

                var viewModel = new DoctorFormViewModel
                {
                    Doctor        = doctor,
                    Availability  = availability,
                    DaysAvailable = days,
                };
                return(View("DoctorForm", viewModel));
            }
        }