public override void Add(object objetType) { if (objetType is Doctor) { Doctor doctor = (Doctor)objetType; Student.Doctors.Add(doctor); } if (objetType is NextOfKin) { NextOfKin nextOfKin = (NextOfKin)objetType; Student.NextOfKin.Add(nextOfKin); } if (objetType is EmergencyContact) { EmergencyContact emergencyContact = (EmergencyContact)objetType; Student.EmergencyContacts.Add(emergencyContact); } if (objetType is MedicalCondition) { MedicalCondition medicalCondition = (MedicalCondition)objetType; Student.MedicalConditions.Add(medicalCondition); } if (objetType is StudentNote) { StudentNote studentNote = (StudentNote)objetType; Student.StudentNotes.Add(studentNote); } }
/// <summary> /// Binds Next of Kin Information from Different Collection /// </summary> protected void BindNextOfKinInfo() { OMMDataContext context = new OMMDataContext(); //if (context.NextOfKins.FirstOrDefault(P => P.ContactID == _ContactID) == null) // ShowNotFoundMessage(); //else //{ if (_IsEditMode) { NextOfKin entity = context.NextOfKins.FirstOrDefault(P => P.ID == _ID && P.ContactID == _ContactID); if (entity == null) { ShowNotFoundMessage(); } else { tbxName.Text = entity.Name; tbxRelationShip.Text = entity.Relationship; tbxAddress.Text = entity.Address; tbxPostCode.Text = entity.Postcode; //ddlCountry.SetSelectedItem((entity.CountryID.ToString().Trim().IsNullOrEmpty()) ? //String.Empty : entity.CountryID.ToString().Trim()); ddlCountry.SetSelectedItem(entity.CountryID.ToString()); tbxHomeNumber.Text = entity.HomeNumber; tbxWorkNumber.Text = entity.WorkNumber; tbxMobile.Text = entity.MobileNumber; } } //} }
private static void AddOneCabinWithCampers(CampSleepawayContext context) { NextOfKin next = context.NextOfKins.Find(1); List <NextOfKin> nextOfKins = new List <NextOfKin>(); nextOfKins.Add(next); List <Camper> campers = new List <Camper> { new Camper { FirstName = "Karl", LastName = "Ekman", NextOfKins = nextOfKins }, new Camper { FirstName = "Berit", LastName = "Ekman", NextOfKins = nextOfKins }, new Camper { FirstName = "Lisa", LastName = "Ekdhal", NextOfKins = nextOfKins } }; Cabin cabin = context.Cabins.Find(1); cabin.Counselor = context.Counselors.Find(2); context.Cabins.Add(cabin); context.SaveChanges(); }
private static void CheckInCamper() { using (CampSleepawayContext context = new CampSleepawayContext()) { string bigfirstname = MenuUtils.AskForString("Vad heter målsmannen i förnamn?"); string biglastname = MenuUtils.AskForString("Vad heter målsmannen i efternamn?"); bool oneMore = true; List <Camper> family = new List <Camper>(); while (oneMore) { string firstname = MenuUtils.AskForString("Vad heter kamparen i förnamn?"); string lastname = MenuUtils.AskForString("Vad heter kamparen i efternamn?"); family.Add(new Camper { FirstName = firstname, LastName = lastname }); oneMore = MenuUtils.AlternetivesMenu(1, new string[] { "Ja", "Nej" }, "Var det alla?") == 0 ? false : true; } NextOfKin nextOfKin = new NextOfKin { FirstName = bigfirstname, LastName = biglastname, Campers = family }; context.NextOfKins.Add(nextOfKin); // Let user choose cabin for all campers. bool chooseCabin = MenuUtils.AlternetivesMenu(1, new string[] { "Ja, nu på en gång.", "Nej, det kan göras senare." }, "Vill du välja stugor själv?") == 0 ? true : false; if (chooseCabin) { foreach (var camper in nextOfKin.Campers) { var cabins = (from emptyCabins in context.Cabins where emptyCabins.Campers.Count <= 3 select emptyCabins).ToList(); // Will query for all empty cabins string[] cabinText = new string[cabins.Count()]; int y = 0; foreach (var cabin in cabins) { context.Entry(cabin).Collection(c => c.Campers).Load(); cabinText[y] = String.Format($"{cabin.Name}: {3 - cabin.Campers.Count}"); } // Let user choose from cabins, and see remaining spots. int cabinChoice = MenuUtils.AlternetivesMenu(0, cabinText, "välj cabin för " + camper.FirstName + "."); y++; camper.Cabin = cabins[cabinChoice]; cabins[cabinChoice].Campers.Add(camper); // Loop until all campers has a cabin. } } context.SaveChanges(); } }
public override void AddNextOfKin(NextOfKin nextOfKin) { DataBase db = new NextOfKinData(); int nextofKinId = db.Add(nextOfKin, Student.PersonId); nextOfKin.PersonId = nextofKinId; }
private static void CheckCampersCouncelour() { using (CampSleepawayContext context = new CampSleepawayContext()) { //====== // Ask for Next of kin info string bigfirstname = MenuUtils.AskForString("Vad heter målsmannen i förnamn?"); string biglastname = MenuUtils.AskForString("Vad heter målsmannen i efternamn?"); // Query data from next of kin NextOfKin nextOfKin = (from nextOfKins in context.NextOfKins where nextOfKins.FirstName == bigfirstname && nextOfKins.LastName == biglastname select nextOfKins).FirstOrDefault(); context.Entry(nextOfKin).Collection(c => c.Campers).Load(); int campersCount = nextOfKin.Campers.Count(); string[] campersFirstName = new string[campersCount]; string[] campersLastName = new string[campersCount]; int[] camperIds = new int[campersCount]; int i = 0; foreach (var campersInQuery in nextOfKin.Campers) { campersFirstName[i] = campersInQuery.FirstName; campersLastName[i] = campersInQuery.LastName; camperIds[i] = campersInQuery.CamperId; i++; } // Checks out and prints all the campers of the next of kin. int choice = MenuUtils.AlternetivesMenu(0, campersFirstName, "Vilken unge vill du hämta?"); //var camperQuery = (from camper in context.Campers // where camper.LastName == campersLastName[choice] && // camper.FirstName == campersFirstName[choice] // select camper.Cabin).ToList(); string camperFirstName = campersFirstName[choice]; string camperLastName = campersLastName[choice]; int camperId = camperIds[choice]; //====== string camperName = MenuUtils.AskForString("Vad heter parveln i förnamn?"); var camperQuery = (from camper in context.Campers where camper.CamperId == camperId select camper.Cabin).ToList(); // visa info om valda kabin Cabin cabinInfo = camperQuery[0]; context.Entry(cabinInfo).Reference(c => c.Counselor).Load(); if (cabinInfo.Counselor != null) { Console.WriteLine($"\nGruppledarens namn: {cabinInfo.Counselor.FirstName}"); } else { Console.WriteLine("Hittade ingen råggivare till den kamparen"); } } MenuUtils.PauseUntilFeedback("Tryck en knapp för att fortsätta"); }
public override void AddNextOfKin(NextOfKin nextOfKin) { throw new NotImplementedException("not implemented"); //DataBase db = new NextOfKinData(); //int nextofKinId = db.Add(nextOfKin, Student.PersonId); //nextOfKin.PersonId = nextofKinId; }
/// <summary> /// Add Next Of Kin /// </summary> /// <param name="nextOfKin"></param> /// <returns></returns> public NextOfKin AddNextOfKin(NextOfKin nextOfKin) { _context.NextOfKins.Add(nextOfKin); _context.SaveChanges(); return(nextOfKin); }
public ActionResult DeleteConfirmed(string id) { NextOfKin nextOfKin = db.NextOfKins.Find(id); db.NextOfKins.Remove(nextOfKin); db.SaveChanges(); return(RedirectToAction("Index")); }
public NextOfKin SaveNextOfKin(NextOfKin kin) { SqlServerConnection conn = new SqlServerConnection(); kin.Id = conn.SqlServerUpdate("IF NOT EXISTS (SELECT nk_idnt FROM PersonNok WHERE nk_idnt=" + kin.Id + ") BEGIN INSERT INTO PersonNok(nk_person, nk_names, nk_relation, nk_physical, nk_mobile, nk_email) OUTPUT INSERTED.nk_idnt VALUES (" + kin.Person.Id + ", '" + kin.Name + "', '" + kin.Relation + "', '" + kin.Physical + "', '" + kin.Mobile + "', '" + kin.Email + "') END ELSE BEGIN UPDATE PersonNok SET nk_names='" + kin.Name + "', nk_relation='" + kin.Relation + "', nk_physical='" + kin.Physical + "', nk_mobile='" + kin.Mobile + "', nk_email='" + kin.Email + "' OUTPUT INSERTED.nk_idnt WHERE nk_idnt=" + kin.Id + " END"); return(kin); }
public ActionResult AddPatient(PatientModel o) { NextOfKin _NextOfKin = new NextOfKin(); Patient _patient = new Patient(); if (o.Id == 0) { //Add NextOfKin _NextOfKin.NokAddressLine1 = o.nextOfKinModel.NokAddressLine1; _NextOfKin.NokAddressLine2 = o.nextOfKinModel.NokAddressLine2; _NextOfKin.NokAddressLine3 = o.nextOfKinModel.NokAddressLine3; _NextOfKin.NokAddressLine4 = o.nextOfKinModel.NokAddressLine4; _NextOfKin.NokName = o.nextOfKinModel.NokName; _NextOfKin.NokRelationshipCode = o.nextOfKinModel.NokRelationshipCode; _NextOfKinBLL.Add(_NextOfKin); _NextOfKinBLL.Save(); //Add Patient _patient.DoctorId = o.DoctorId; _patient.HomeTelephoneNumber = o.HomeTelephoneNumber; _patient.NextOfKinId = _NextOfKin.Id; _patient.PasNumber = o.PasNumber; _patient.PatientName = o.PatientName; _patient.SexCodeId = o.SexCodeId; _PatientBLL.Add(_patient); _PatientBLL.Save(); } else { var pateint = _PatientBLL.GetItemById(o.Id); var nokToRelation = _NextOfKinBLL.GetAll().Where(a => a.Id == pateint.NextOfKinId).FirstOrDefault(); //remove nok if (nokToRelation != null) { _NextOfKin.Id = nokToRelation.Id; _NextOfKin.NokAddressLine1 = o.nextOfKinModel.NokAddressLine1; _NextOfKin.NokAddressLine2 = o.nextOfKinModel.NokAddressLine2; _NextOfKin.NokAddressLine3 = o.nextOfKinModel.NokAddressLine3; _NextOfKin.NokAddressLine4 = o.nextOfKinModel.NokAddressLine4; _NextOfKin.NokName = o.nextOfKinModel.NokName; _NextOfKin.NokRelationshipCode = o.nextOfKinModel.NokRelationshipCode; _NextOfKinBLL.Update(_NextOfKin); _NextOfKinBLL.Save(); } //Update _patient.Id = pateint.Id; _patient.DoctorId = o.DoctorId; _patient.HomeTelephoneNumber = o.HomeTelephoneNumber; _patient.NextOfKinId = _NextOfKin.Id; _patient.PasNumber = o.PasNumber; _patient.PatientName = o.PatientName; _patient.SexCodeId = o.SexCodeId; _PatientBLL.Update(_patient); _PatientBLL.Save(); } return(RedirectToAction("Index")); }
private static void AddOneNextOfKin(CampSleepawayContext context) { NextOfKin nextOfKin = new NextOfKin { FirstName = "Bro" }; context.NextOfKins.Add(nextOfKin); context.SaveChanges(); }
private void initEmployee() { _Services = new HRManagementService(); _Person = new Person(); _Qualification = new Qualification(); _Education = new Education(); _ContactInfo = new ContactInfo(); _ContactPhone = new ContactPhone(); _NextOfKin = new NextOfKin(); }
// // GET: /NextOfKin/Delete/5 public ActionResult Delete(int id = 0) { NextOfKin nextofkin = db.NextOfKin.Find(id); if (nextofkin == null) { return(HttpNotFound()); } return(View(nextofkin)); }
public ActionResult Edit(NextOfKin nextofkin) { if (ModelState.IsValid) { db.Entry(nextofkin).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(nextofkin)); }
public ActionResult Edit([Bind(Include = "IdNo,FName,LName,PhoneNumber,Address,PassengerId")] NextOfKin nextOfKin) { if (ModelState.IsValid) { db.Entry(nextOfKin).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PassengerId = new SelectList(db.Passengers, "PassengerId", "FirstName", nextOfKin.PassengerId); return(View(nextOfKin)); }
private static bool ContainsNextOfKin(NextOfKin nextOfKin, List <NextOfKin> nextOfKins) { foreach (NextOfKin kin in nextOfKins) { if (kin.NextOfKinId == nextOfKin.NextOfKinId) { return(true); } } return(false); }
public ActionResult Create(NextOfKin nextofkin) { if (ModelState.IsValid) { db.NextOfKin.Add(nextofkin); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(nextofkin)); }
public ActionResult Create([Bind(Include = "IdNo,FName,LName,PhoneNumber,Address,PassengerId")] NextOfKin nextOfKin) { if (ModelState.IsValid) { db.NextOfKins.Add(nextOfKin); db.SaveChanges(); return(RedirectToAction("Create", "Laggages")); } ViewBag.PassengerId = new SelectList(db.Passengers, "PassengerId", "FirstName", nextOfKin.PassengerId); return(View(nextOfKin)); }
private List <NextOfKin> GetOtherNextOfKin(List <NextOfKin> nextOfKin, List <NextOfKin> studentNextOfKin) { foreach (NextOfKin nofk in studentNextOfKin) { NextOfKin doctor = nextOfKin.Find(x => x.PersonId == nofk.PersonId); if (doctor != null) { nextOfKin.Remove(doctor); } } return(nextOfKin); }
//[Authorize(Policy = "NextOfKin.create")] public IActionResult Create([FromBody] NextOfKin objNextOfKin) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } NextOfKinRepository.Add(objNextOfKin); NextOfKinRepository.Commit(); return(Ok(Json(objNextOfKin))); //CreatedAtRouteResult result = CreatedAtRoute("Get NextOfKin", new { controller = " NextOfKin", id = objNextOfKin.Id }, objNextOfKin); //return result; }
// GET: NextOfKins/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } NextOfKin nextOfKin = db.NextOfKins.Find(id); if (nextOfKin == null) { return(HttpNotFound()); } return(View(nextOfKin)); }
public int DeleteNextOfKin(NextOfKin nextOfKin) { _context.NextOfKin.Remove(nextOfKin); try { return(_context.SaveChanges()); } catch (Exception ex) { Clf.CreateErrorLog(ErrorLogPath, "DB Transaction Error at DeleteNextOfKin Method: " + ex.Message + ": " + ex.InnerException); } return(0); }
public RegistrationNewViewModel() { DoB = ""; Room = 0; Currency = new GlobalService().GetGlobalProperties(_Constants.BASE_CURRENCY).Value; Patient = new Patient(); NextOfKin = new NextOfKin(); Billables = new BillableServices(); Gender = InitializeGender(); Nation = InitializeNationality(); Relation = InitializeRelationship(); Destination = InitializeRoomToSend(); }
private void button7_Click(object sender, EventArgs e) { using (database = new HBSDataContext()) { try { Address address = new Address(); address.StreetName = txtStreetName.Text; address.Suburb = txtSuburb.Text; address.City = txtCity.Text; address.Province = txtProvince.Text; address.PostalCode = txtCode.Text; NextOfKin nextOfKin = new NextOfKin(); nextOfKin.NkName = txtNOK.Text; nextOfKin.NkPhoneNumber = txtNOKPhone.Text; Gender gender = database.Genders.Single(x => x.GenderId == int.Parse(cmbGender.SelectedValue.ToString())); EmployeeType employeeType = database.EmployeeTypes.Single(x => x.EmployeeTypeId == int.Parse(cmbType.SelectedValue.ToString())); Employee employee = new Employee(); employee.Name = txtName.Text; employee.Surname = txtSurname.Text; employee.Email = txtEmail.Text; employee.PhoneNumber = txtPhone.Text; database.Addresses.InsertOnSubmit(address); database.NextOfKins.InsertOnSubmit(nextOfKin); employee.Address = address; employee.NextOfKin = nextOfKin; employee.Gender = gender; employee.EmployeeType = employeeType; database.Employees.InsertOnSubmit(employee); database.SubmitChanges(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { } this.Close(); mainForm.loadEmployees(); MessageBox.Show("New Employee Added"); } }
public ActionResult Edit(BasicVM basic, NextOfKinVM nextOfSkin, GpDetailVM gpDetail) { if (ModelState.IsValid) { using (var transaction = db.Database.BeginTransaction()) { var basicObj = db.Basics.Find(basic.PasNumber); if (basicObj == null) { return(HttpNotFound()); } basicObj.DateOfBirth = basic.DateOfBirth; basicObj.Forenames = basic.Forenames; basicObj.HomeTelephoneNumber = basic.HomeTelephoneNumber; basicObj.SexCode = basic.SexCode; basicObj.Surname = basic.Surname; db.Entry(basicObj).State = EntityState.Modified; db.SaveChanges(); var nextOfSkinObj = new NextOfKin(); nextOfSkinObj.NokAddressLine1 = nextOfSkin.NokAddressLine1; nextOfSkinObj.NokAddressLine2 = nextOfSkin.NokAddressLine2; nextOfSkinObj.NokAddressLine3 = nextOfSkin.NokAddressLine3; nextOfSkinObj.NokAddressLine4 = nextOfSkin.NokAddressLine4; nextOfSkinObj.NokName = nextOfSkin.NokName; nextOfSkinObj.NokPostcode = nextOfSkin.NokPostcode; nextOfSkinObj.NokRelationshipCode = nextOfSkin.NokRelationshipCode; nextOfSkinObj.PatientPasNumber = basicObj.PasNumber; db.Entry(nextOfSkinObj).State = EntityState.Modified; db.SaveChanges(); var gpDetailsObj = new GpDetail(); gpDetailsObj.GpCode = gpDetail.GpCode; gpDetailsObj.GpInitials = gpDetail.GpInitials; gpDetailsObj.GpPhone = gpDetail.GpPhone; gpDetailsObj.GpSurname = gpDetail.GpSurname; gpDetailsObj.PatientPasNumber = basicObj.PasNumber; db.Entry(gpDetailsObj).State = EntityState.Modified; db.SaveChanges(); transaction.Commit(); } return(RedirectToAction("Index")); } return(View(basic)); }
public static void Main() { using (var connection = new SqliteConnection("DataSource=:memory:")) { connection.Open(); var context = StudentDbContext.Create(connection); var classes = new ClassRepository(context); classes.Create(new Class { Id = 1, Name = "Math" }); classes.Create(new Class { Id = 2, Name = "History" }); var students = new StudentRepository(context); var math = classes.Get(1); var history = classes.Get(2); var jim = new Student { Id = 1, Name = "Jim Doe", Classes = new List <Class> { math, history } }; students.Create(jim); var nextOfKins = students.Get(1); nextOfKins.NextOfKins = new List <NextOfKin> { NextOfKin.Create("John Doe"), NextOfKin.Create("Jane Doe") }; students.Update(nextOfKins); var residence = students.Get(1); nextOfKins.Hometown = City.Create("Oslo"); students.Update(nextOfKins); new StudentReport(connection, 1).Write(); new ClassesReport(connection).Write(); Console.Out.WriteLine("Classes: " + context.Classes.Count()); Console.Out.WriteLine("Students: " + context.Students.Count()); } }
// GET: NextOfKins/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } NextOfKin nextOfKin = db.NextOfKins.Find(id); if (nextOfKin == null) { return(HttpNotFound()); } ViewBag.PassengerId = new SelectList(db.Passengers, "PassengerId", "FirstName", nextOfKin.PassengerId); return(View(nextOfKin)); }
private List <NextOfKin> GetOtherNextOfKin(List <NextOfKin> nextOfKin, List <NextOfKin> studentNextOfKin) { //List<Doctor> otherDoctors = new List<Doctor>(); //foreach (Doctor dr in doctors) //{ foreach (NextOfKin nofk in studentNextOfKin) { NextOfKin doctor = nextOfKin.Find(x => x.PersonId == nofk.PersonId); if (doctor != null) { nextOfKin.Remove(doctor); } } //} return(nextOfKin); }
//[Authorize(Policy = "NextOfKin.view")] ////[Authorize("View NextOfKin ")] public IActionResult Get(Int64 id) { //NextOfKin objNextOfKin = NextOfKinRepository.GetSingle(u => u.PKColumn == id); NextOfKin objNextOfKin = NextOfKinRepository.GetSingle(u => u.NextOfKinID == id); if (objNextOfKin != null) { return(new OkObjectResult(objNextOfKin)); } else { return(NotFound()); } }