예제 #1
0
        public HospitalStaffViewModel AddHospitalStaff([FromBody] HospitalStaffViewModel hospitalStaffViewModel)
        {
            HospitalStaff hospitalStaff = new HospitalStaff()
            {
                Id           = hospitalStaffViewModel.Id,
                IsActive     = true,
                DateCreated  = DateTime.UtcNow,
                DateModified = DateTime.UtcNow,
                Name         = hospitalStaffViewModel.Name,
                HospitalId   = hospitalStaffViewModel.HospitalId,
                StaffRoleId  = hospitalStaffViewModel.StaffRoleId,
                Phone        = hospitalStaffViewModel.Phone,
                Age          = hospitalStaffViewModel.Age,
                Gender       = hospitalStaffViewModel.Gender,
                UniqueId     = hospitalStaffViewModel.UniqueId,
                AddressLine  = hospitalStaffViewModel.AddressLine,
                Area         = hospitalStaffViewModel.Area,
                City         = hospitalStaffViewModel.City,
                State        = hospitalStaffViewModel.State,
                Pincode      = hospitalStaffViewModel.Pincode,
                District     = hospitalStaffViewModel.District,
                Country      = hospitalStaffViewModel.Country,
                Username     = hospitalStaffViewModel.Username,
                Password     = hospitalStaffViewModel.Password
            };

            _context.HospitalStaff.Add(hospitalStaff);
            _context.SaveChanges();

            hospitalStaffViewModel.Id          = hospitalStaff.Id;
            hospitalStaffViewModel.HospitalId  = hospitalStaff.HospitalId;
            hospitalStaffViewModel.StaffRoleId = hospitalStaff.StaffRoleId;

            return(hospitalStaffViewModel);
        }
예제 #2
0
 public HospitalStaff AddHospitalStaff([FromBody] HospitalStaff hospitalStaff)
 {
     _context.HospitalStaff.Add(hospitalStaff);
     _context.SaveChanges();
     return(hospitalStaff);
 }
        public async Task <ActionResult> Add(string user, string emailaddress, string password, string confirmpassword, string firstname, string middlename, string lastname, string dob, string phonenumber, string altphonenumber)
        {
            //Stores data in master user table
            ApplicationUser NewUser = new ApplicationUser();

            NewUser.UserName = emailaddress;
            NewUser.Email    = emailaddress;
            //Pass data to table
            IdentityResult result = await UserManager.CreateAsync(NewUser, password);

            //If it succeed
            if (result.Succeeded)
            {
                //If registered user is patient
                if (user == "Patient")
                {
                    Patient newpatient = new Patient();
                    string  id         = NewUser.Id;
                    newpatient.PatientID        = id;
                    newpatient.PatientFName     = firstname;
                    newpatient.PatientMName     = middlename;
                    newpatient.PatientLName     = lastname;
                    newpatient.PatientBirthDate = dob;
                    newpatient.PatientEmail     = emailaddress;
                    newpatient.PatientPhone     = phonenumber;
                    newpatient.PatientAltPhone  = altphonenumber;
                    db.Patients.Add(newpatient);
                    db.SaveChanges();
                }
                //registered user is doctor
                else if (user == "Doctor")
                {
                    Doctor newdoctor = new Doctor();
                    string id        = NewUser.Id;
                    newdoctor.DoctorID        = id;
                    newdoctor.DoctorFName     = firstname;
                    newdoctor.DoctorMName     = middlename;
                    newdoctor.DoctorLName     = lastname;
                    newdoctor.DoctorBirthDate = dob;
                    newdoctor.DoctorEmail     = emailaddress;
                    newdoctor.DoctorPhone     = phonenumber;
                    newdoctor.DoctorAltPhone  = altphonenumber;
                    db.Doctors.Add(newdoctor);
                    db.SaveChanges();
                }
                //If registered user is hspital staff
                else if (user == "Hospitalstaff")
                {
                    HospitalStaff newstaff = new HospitalStaff();
                    string        id       = NewUser.Id;
                    newstaff.StaffID        = id;
                    newstaff.StaffFName     = firstname;
                    newstaff.StaffMNmae     = middlename;
                    newstaff.StaffNmae      = lastname;
                    newstaff.StaffBirthDate = dob;
                    newstaff.StaffEmail     = emailaddress;
                    newstaff.StaffPhone     = phonenumber;
                    db.hospitalStaffs.Add(newstaff);
                    db.SaveChanges();
                }
                else
                {
                    Debug.WriteLine(user);
                }
            }

            return(View());
        }