public void UpdateDoctor(Models.Doctor doctor, int id) { var data = hospitalContext.Doctors.Single(z => z.DoctorId == id); data.DoctorName = doctor.DoctorName; data.Departments = doctor.Departments; hospitalContext.SaveChanges(); }
public ReservationsController(ReservationsDoc view) { this.view = view; this.reservationModel = new Models.Reservation(); this.employeeModel = new Models.Employee(); this.doctorModel = new Models.Doctor(); }
public void OnGet(string id) { var userId = ""; var doctors = new Models.Doctor(); var user = new ApplicationUser(); if (id == null) { userId = User.FindFirstValue(ClaimTypes.NameIdentifier); doctors = _context.Doctor.Include(i => i.User).Include(p => p.Picture).AsNoTracking().FirstOrDefault(i => i.Id == userId); user = _context.Users.Where(u => u.Id == userId).AsNoTracking().SingleOrDefault(); } if (id != null) { doctors = _context.Doctor.Include(i => i.User).Include(p => p.Picture).Include(u => u.User).AsNoTracking().FirstOrDefault(i => i.Id == id); user = _context.Users.Where(u => u.Id == id).AsNoTracking().SingleOrDefault(); } pictureBase64 = Convert.ToBase64String(doctors.Picture.ImageData, 0, doctors.Picture.ImageData.Length); Doctor = new DoctorEditViewModel { FirstName = user.FirstName, LastName = user.LastName, Email = user.Email, PhoneNumber = user.PhoneNumber, Sex = doctors.Sex, Specialization = doctors.Specializaiton, Id = doctors.Id, Picture = doctors.Picture }; }
public async Task <IActionResult> Index(int id) { if (User?.Identity?.IsAuthenticated ?? false) { var doctorEmail = User.Claims.FirstOrDefault(c => c.Type == DoctorAccountConfig.Email).Value; var doctor = HttpContext.Session.Get <Models.Doctor>(sessionKeyName + doctorEmail); if (doctor == null) { doctor = new Models.Doctor { Email = doctorEmail, Name = User.Claims.FirstOrDefault(c => c.Type == DoctorAccountConfig.Name).Value, Image = new Uri(User.Claims.FirstOrDefault(c => c.Type == DoctorAccountConfig.ImageUri).Value), Patients = await(new DoctorController(IPConfig, JsonStructureConfig).Read(doctorEmail)) }; HttpContext.Session.Set(sessionKeyName + doctorEmail, doctor); } var patient = doctor.Patients.FirstOrDefault(x => x.Id == id); if (patient == null) { return(Redirect("~/dashboard/homepage")); } ViewBag.Doctor = doctor; return(View(patient)); } else { return(Redirect("~/signin")); } }
public bool updateDoctor(Models.Doctor dObj) { bool status = false; try { CureWellDataAccessLayer.Models.Doctor doc = new CureWellDataAccessLayer.Models.Doctor(); if (ModelState.IsValid) // If we were able to create a DAL 's Doctor type object { // Assign incoming object 's attributes to doc's properties. // Here frontend is only updating the name, but also needs to id property in order to look for the object inside dababase. // Repo's updatedoc method will find obj in the database by id, then update the name. doc.DoctorName = dObj.DoctorName; doc.DoctorId = dObj.DoctorId; // Repo method is expecting DAL object, that's why we needed to create one and assign property value with incoming object's key/value. status = rep.UpdateDoctorDetails(doc); } } catch (Exception) { status = false; } return(status); }
public DoctorTimetablesController(TimeTablesDoc view) { this.view = view; this.employeeModel = new Models.Employee(); this.doctorModel = new Models.Doctor(); this.workingHoursModel = new Models.WorkingHours(); }
/// <summary> /// Get a doctor with a specific Id /// </summary> /// <param name="id">The id of the doctor to be returned</param> /// <returns>A doctor with a list of its patient</returns> public Models.Doctor GetDoctorByID(int doctorId) { var DBDoctor = _context.Doctors.Find(doctorId); var doctor = new Models.Doctor(DBDoctor.Id, DBDoctor.Name, DBDoctor.Title); return(doctor); }
public bool Add(Models.Doctor doctor) { using (var db = this.dbContext) { db.Doctors.Add(doctor); return(db.SaveChanges() > 0); } }
/// <summary> /// Get a doctor with a specific Id /// </summary> /// <param name="id">The id of the doctor to be returned</param> /// <returns>A doctor with a list of its patient</returns> public async Task <Models.Doctor> GetDoctorByIDAsync(int doctorId) { var DBDoctor = await _context.Doctors.FindAsync(doctorId); var doctor = new Models.Doctor(DBDoctor.Id, DBDoctor.Name, DBDoctor.Title); return(doctor); }
public ReservationsController(Reservations view) { this.view = view; this.reservationModel = new Models.Reservation(); this.serviceModel = new Models.Service(); this.patientModel = new Models.Patient(); this.doctorModel = new Models.Doctor(); this.nurseModel = new Models.Nurse(); }
public AnalyticsController(ManagerAnalytics view) { this.view = view; this.serviceModel = new Models.Service(); this.patientModel = new Models.Patient(); this.doctorModel = new Models.Doctor(); this.nurseModel = new Models.Nurse(); this.reservationAnalytics = new Models.ReservationAnalytics(); }
public ActionResult HtmlHelperExample() { Doctor obj = new Models.Doctor(); obj.DoctorName = "Vidhi"; ViewBag.Doctors = new SelectList(db.Doctors.ToList(), "DoctorId", "DoctorName", 3); return(View(obj)); }
public UsersController(Users view) { this.view = view; this.userModel = new Models.User(); this.roleModel = new Models.Role(); this.sectorModel = new Models.Sector(); this.operatorModel = new Models.Operator(); this.doctorModel = new Models.Doctor(); this.nurseModel = new Models.Nurse(); }
public PrescriptionsController(Prescription view) { this.view = view; this.reservationModel = new Models.Reservation(); this.doctorModel = new Models.Doctor(); this.allergenModel = new Models.Allergen(); this.medicamentModel = new Models.Medicament(); this.prescriptionModel = new Models.Prescription(); this.prescriptionMedicamentModel = new Models.PrescriptionMedicament(); }
public ActionResult LogOut() { Session["Do"] = new Models.Doctor(); Session["Dologin"] = ""; Session["msg"] = ""; Session["Dng"] = ""; Session["NT"] = ""; Session["AP"] = ""; return(RedirectToAction("Index", "Home")); }
public async Task <object> Create([FromBody] Models.Doctor item) { var doctorJson = new JObject { { JsonDataConfig.Root, JObject.Parse(JsonConvert.SerializeObject(item, serializerSettings)) } }; await APIUtils.PostAsync(IPConfig.GetTotalUrl() + JsonDataConfig.Url, doctorJson.ToString()); return(Empty); }
// GET public ActionResult Details(Models.Doctor doctor) { try { var obj = repObj.GetDoctor(doctor.DoctorId); return(View(_mapper.Map <Models.Doctor>(obj))); } catch (Exception) { return(View("Error")); } }
public DoctorAddOrUpdateResponseDto AddOrUpdate(DoctorAddOrUpdateRequestDto request) { var entity = _repository.GetAll() .FirstOrDefault(x => x.Id == request.Id && x.IsDeleted == false); if (entity == null) { _repository.Add(entity = new Models.Doctor()); } entity.Name = request.Name; _uow.SaveChanges(); return(new DoctorAddOrUpdateResponseDto(entity)); }
/// <summary> /// Adds a doctor to the database /// </summary> /// <param name="doctor">The doctor to be added to the database</param> public Models.Doctor AddDoctor(Models.Doctor doctor) { var newDoctor = new DataModel.Doctor { Name = doctor.Name, Title = doctor.Title }; _context.Doctors.Add(newDoctor); _context.SaveChanges(); doctor.Id = newDoctor.Id; return(doctor); }
/// <summary> /// Adds a doctor to the database /// </summary> /// <param name="doctor">The doctor to be added to the database</param> public async Task <Models.Doctor> AddDoctorAsync(Models.Doctor doctor) { var newDoctor = new DataModel.Doctor { Name = doctor.Name, Title = doctor.Title }; await _context.Doctors.AddAsync(newDoctor); await _context.SaveChangesAsync(); doctor.Id = newDoctor.Id; return(doctor); }
public static List <Models.Doctor> FindDoctorByDid(string _did) { List <Models.Doctor> result = new List <Models.Doctor>(); SqlConnection conn = DB.GetConntion(); SqlCommand cmd = new SqlCommand("select Name, Did, Department from dbo.Doctors", conn); SqlDataReader str = cmd.ExecuteReader(System.Data.CommandBehavior.CloseConnection); while (str.Read()) { Models.Doctor dObj = new Models.Doctor(); str.GetString(0); } return(result); }
public ActionResult DoLogin(Models.Doctor doc) { var v = db.Doctors.Where(e => e.Email.ToLower() == doc.Email && e.PassWord == doc.PassWord).ToList(); if (v.Count <= 0) { Session["Dng"] = "You Are Not An Admin. Denger Request"; Session["msg"] = "Invalid Login Please Check Your Email Or PassWard"; return(View(doc)); } Session["Do"] = v.First(); Session["Dologin"] = "******"; return(RedirectToAction("Index", "Home")); }
public ImageSource getSource(Models.Doctor d) { Image imgtemp = new Image(); if (d != null) { imagesource = new BitmapImage(new Uri(String.Format("ms-appx:///Assets/Doc{0}.jpg", d.ID), UriKind.Absolute)); } else { imagesource = new BitmapImage(); } imgtemp.Source = imagesource; return(imgtemp.Source); }
public async Task <IActionResult> OnPost() { ApplicationUser user = new ApplicationUser { UserName = Doctor.Email, Email = Doctor.Email, FirstName = Doctor.FirstName, LastName = Doctor.LastName, PhoneNumber = Doctor.Phone }; await _userManager.CreateAsync(user, Doctor.Password); var path = Path.Combine(_hostingEnvironment.WebRootPath, "images", "Default-welcomer.png"); var imageFileStream = System.IO.File.OpenRead(path); byte[] imageByteArray; using (var memoryStream = new MemoryStream()) { imageFileStream.CopyTo(memoryStream); imageByteArray = memoryStream.ToArray(); } Models.Doctor dct = new Models.Doctor { Id = user.Id, Sex = Doctor.Sex, Specializaiton = Doctor.Specialization, User = user, Picture = new ProfilePicture() { Id = Guid.NewGuid().ToString(), ImageData = imageByteArray } }; var doc = await _userManager.FindByIdAsync(dct.Id); await _userManager.AddToRoleAsync(doc, "Doctor"); _context.Doctor.Add(dct); await _context.SaveChangesAsync(); return(RedirectToPage("/Doctor/Index")); }
public async Task <IActionResult> Index() { if (User?.Identity?.IsAuthenticated ?? false) { var email = User.Claims.FirstOrDefault(c => c.Type == DoctorAccountConfig.Email).Value; var doctor = HttpContext.Session.Get <Models.Doctor>(sessionKeyName + email); if (doctor == null) { var doctorController = new DoctorController(IPConfig, JsonStructureConfig); var name = User.Claims.FirstOrDefault(c => c.Type == DoctorAccountConfig.Name).Value; var image = new Uri(User.Claims.FirstOrDefault(c => c.Type == DoctorAccountConfig.ImageUri).Value); doctor = (await doctorController.Read()).FirstOrDefault(x => x.Email == email); if (doctor == null) { doctor = new Models.Doctor { Email = email, Name = name, Image = image, Patients = new List <Models.Patient>() }; await doctorController.Create(doctor); } else { doctor.Image = image; doctor.Patients = await doctorController.Read(email); } HttpContext.Session.Set(sessionKeyName + email, doctor); } return(View(doctor)); } else { return(Redirect("~/signin")); } }
// POST public ActionResult UpdateDoctorDetails(Models.Doctor doctor) { try { bool status = repObj.UpdateDoctorDetails(_mapper.Map <Doctor>(doctor)); if (status) { return(View("Success")); } else { return(View("Edit", doctor)); } } catch (Exception) { return(View("Error")); } }
/// <summary> /// Get a list of doctors asynchornusly. /// </summary> /// <returns>A task that can be awaited with the list of doctors.</returns> public async Task <IEnumerable <Models.Doctor> > GetDoctorsAsync() { var DBDoctors = await _context.Doctors .Include(o => o.Patients) .ToListAsync(); List <Models.Doctor> ModelDoctors = new List <Models.Doctor>(); foreach (var dbdoctor in DBDoctors) { Models.Doctor next = new Models.Doctor(dbdoctor.Id, dbdoctor.Name, dbdoctor.Title) { Patients = (List <Models.Patient>)GetDoctorPatients(dbdoctor.Id) }; ModelDoctors.Add(next); } return(ModelDoctors); }
public bool addDoctor(Models.Doctor dObj) { bool status = false; // Frontend is passing in whole object. try { // DAL is expecting a DAL Type Doctor CureWellDataAccessLayer.Models.Doctor doc = new CureWellDataAccessLayer.Models.Doctor(); // Id is columnd id, will will be generated automatially so we dont need to give. // Here we can do dObj.DoctorName because frontend Doctor model interface has doctorName key, it is not case sensitive, as long as it matches backend property name. doc.DoctorName = dObj.DoctorName; status = rep.AddDoctor(doc); } catch (Exception) { status = false; } return(status); }
/// <summary> /// Map a DB apointment to an equivilent model apointment. Will not fill in doctor, or patient reference. /// </summary> /// <param name="Dbappointment">A DB version of the apointment to be converted.</param> /// <returns>A model version of the given apointment.</returns> internal static Models.Appointment MapApointment(DataModel.Appointment Dbappointment, Models.Doctor doctor = null) { return(new Models.Appointment(Dbappointment.Id, Dbappointment.Notes, doctor)); }
/** * Controller to submit user information */ public async void handleSubmit() { try { Cursor.Current = Cursors.WaitCursor; int role = (int)this.view.CBox.comboBox.SelectedValue; string email = this.view.FormEmailTxtBox.Text; string password = this.view.FormPasswordTxtBox.Text; string firstName = this.view.FormFirstNameTxtBox.Text; string lastName = this.view.FormLastNameTxtBox.Text; string dob = this.view.FormDOBPicker.Value.ToString(DateTimeFormats.MYSQL_DATE); string phoneNumber = this.view.FormPhoneNumberTxtBox.Text; string address = this.view.FormAddressTxtBox.Text; int specialization = (int)this.view.SpecializationCBox.comboBox.SelectedValue; // Check if one role is selected if (role < 1) { MessageBox.Show("Nuk është zgjedhur roli!", "Problem", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } // Create user userModel = new Models.User(); long createdUserId = await userModel.createUser(email, password, role); // Create objects based on selected role if (this.view.SelectedRole == Roles.OPERATOR) { operatorModel = new Models.Operator(); long createdOperatorId = await operatorModel.createOperator( firstName, lastName, dob, createdUserId ); } else if (this.view.SelectedRole == Roles.DOCTOR) { employeeModel = new Models.Employee(); long createdEmployeeId = await employeeModel.createEmployee( firstName, lastName, phoneNumber, address, dob, createdUserId ); doctorModel = new Models.Doctor(); await doctorModel.createDoctor(specialization, createdEmployeeId); } else if (this.view.SelectedRole == Roles.NURSE) { employeeModel = new Models.Employee(); long createdEmployeeId = await employeeModel.createEmployee( firstName, lastName, phoneNumber, address, dob, createdUserId ); nurseModel = new Models.Nurse(); await nurseModel.createNurse(createdEmployeeId); } this.handleRoleSelection(); Cursor.Current = Cursors.Arrow; MessageBox.Show("Përdoruesi u shtua me sukses!", "Sukses", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception e) { string caption = "Problem në shkrim"; MessageBox.Show(e.Message, caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } }