public async Task <IActionResult> Create([Bind("FullName,DateOfBirth,PlaceOfBirth,Nationality,sect,Insured,PhoneNumber,HealthStatus,HandicapType,BeneficiarID")] Wife wife) { if (ModelState.IsValid) { if (TempData["Field"] != null) { wife.BeneficiarID = (int)TempData.Peek("BenId"); _context.Add(wife); await _context.SaveChangesAsync(); return(RedirectToAction("ChooseField", "Home")); } // TempData["WifeId"] = wife.Id; TempData["Person"] = "Wife"; //CreateModel model = TempData["model"] as CreateModel; CreateModel model = TempData.Get <CreateModel>("model"); model.wife = wife; //TempData["model"] = model; TempData.Put <CreateModel>("model", model); TempData["Name"] = wife.FullName; if (wife.HealthStatus.Equals("Diseased")) { return(Redirect("~/Beneficiars/New/AddingInfo/Wife/Diseases")); } return(Redirect("~/Beneficiars/New/AddingInfo/Wife/Works")); } //ViewData["BeneficiarID"] = new SelectList(_context.Beneficiars, "Id", "FirstName", wife.BeneficiarID); return(View(wife)); }
static void Main(string[] args) { PrintPersonStyle(PersonSytle.tall); Wife wife01; wife01 = new Wife(); wife01.SetName("abc"); Console.WriteLine(wife01.GetName()); Wife wife02 = new Wife(); wife02.Name = "真理"; Console.WriteLine(wife02.Name); Wife[] wifearr = new Wife[3]; wifearr[0] = new Wife("01", 25); wifearr[1] = new Wife("02", 18); wifearr[2] = new Wife("03", 20); Wife smallwife = Abc(wifearr); Console.ReadLine(); }
private bool IsValidFamily() { Individual eldestChild = Children.OrderBy(x => x.BirthDate).FirstOrDefault(); if (MarriageDate.IsAfter(CensusDate) && (eldestChild == null || eldestChild.BirthDate.IsAfter(CensusDate))) { return(false); } if (FamilyID == Family.SOLOINDIVIDUAL || FamilyID == Family.PRE_MARRIAGE) { return(true); // allow solo individual families to be processed } // don't process family if either parent is under 16 //if(Husband != null) rtb.AppendText("Husband : " + Husband.getAge(censusDate) + "\n"); if (Husband != null && Husband.GetMaxAge(CensusDate) < 16) { return(false); } //if(Wife != null) rtb.AppendText("Wife : " + Wife.getAge(censusDate) + "\n"); if (Wife != null && Wife.GetMaxAge(CensusDate) < 16) { return(false); } return(true); }
public async Task <IActionResult> Edit(int id, [Bind("Id,FullName,DateOfBirth,PlaceOfBirth,Nationality,sect,Insured,PhoneNumber,HealthStatus,HandicapType,BeneficiarID")] Wife wife) { if (id != wife.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(wife); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!WifeExists(wife.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("ChooseField", "Home")); //return RedirectToAction(nameof(Index)); } ViewData["BeneficiarID"] = new SelectList(_context.Beneficiars, "Id", "FirstName", wife.BeneficiarID); return(View(wife)); }
public bool BothParentsAlive(FactDate when) { if (Husband is null || Wife is null || FamilyType.Equals(SOLOINDIVIDUAL)) { return(false); } return(Husband.IsAlive(when) && Wife.IsAlive(when) && Husband.GetAge(when).MinAge > 13 && Wife.GetAge(when).MinAge > 13); }
public bool BothParentsAlive(FactDate when) { if (Husband == null || Wife == null || FamilyID == SOLOINDIVIDUAL) { return(false); } return(Husband.IsAlive(when) && Wife.IsAlive(when) && Husband.GetAge(when).MinAge > 13 && Wife.GetAge(when).MinAge > 13); }
void Start() { ThisTr = this.gameObject.GetComponent <Transform>(); SearchPos = ThisTr; resourcel = GameObject.Find("NumUIPrefab").gameObject.GetComponent <ResourceUI>(); Money = GameObject.Find("Husband").gameObject.GetComponent <MoneySystem>(); WifeInfo = GameObject.Find("Wife").gameObject.GetComponent <Wife>(); Hit_motion = GameObject.Find("UI/Hit_Montion").gameObject.GetComponent <HitMontion>(); }
public ActionResult <Wife> CreateWife([FromBody] Wife newWife) { try { return(Ok(_service.CreateWife(newWife))); } catch (System.Exception err) { return(BadRequest(err.Message)); } }
public override void OnInteraction() { HideUI(); DisplayDialogue(); Wife wife = GetComponent <Wife>(); if (wife != null) { wife.SetFemmeTrigger(); } }
public ActionResult <Wife> EditWife(int id, [FromBody] Wife editedWife) { try { editedWife.Id = id; return(Ok(_service.EditWife(editedWife))); } catch (System.Exception err) { return(BadRequest(err.Message)); } }
internal Wife CreateWife(Wife newWife) { string sql = @"INSERT INTO wifes (name, age, skills, knightId) VALUES (@Name, @Age, @Skills, @KnightId); SELECT LAST_INSERT_ID();"; int id = _db.ExecuteScalar <int>(sql, newWife); newWife.Id = id; return(newWife); }
internal Wife GetOneById(int id) { Wife current = _repo.GetOneById(id); if (current == null) { throw new SystemException("INVALID ID"); } else { return(current); } }
private static Wife Abc(Wife[] wifearr) { Wife temp = wifearr[0]; for (int i = 0; i < 3; i++) { if (temp.Age > wifearr[i].Age) { temp = wifearr[i]; } } return(temp); }
internal Wife EditWife(Wife current) { string sql = @"UPDATE wifes SET name = @Name, age = @Age, skills = @Skills WHERE id = @id; SELECT * FROM wifes WHERE id = @id;"; int id = _db.QueryFirstOrDefault <int>(sql, current); return(current); }
internal Wife EditWife(Wife editedWife) { Wife current = GetOneById(editedWife.Id); if (current == null) { throw new SystemException("INVALID ID"); } else { current.Name = editedWife.Name != null ? editedWife.Name : current.Name; current.Age = editedWife.Age != null ? editedWife.Age : current.Age; current.Skills = editedWife.Skills != null ? editedWife.Skills : current.Skills; return(_repo.EditWife(current)); } }
static void Main(string[] args) { Miner m = new Miner(1, "Miner Bob"); Wife w = new Wife(2, "Lady Leia"); EntityManager.Instance.RegisterEntity(m); EntityManager.Instance.RegisterEntity(w); for (int i = 0; i < 10000; i++) { Thread.Sleep(1000); m.Update(); w.Update(); MessageDispatcher.Instance.DispatchDelayedMessages(); } }
private void AddFacts(XmlNode node, string factType) { XmlNodeList list = node.SelectNodes(factType); bool preferredFact = true; foreach (XmlNode n in list) { Fact f = new Fact(n, this, preferredFact); if (f.FactType != Fact.CENSUS) { Facts.Add(f); if (!preferredFacts.ContainsKey(f.FactType)) { preferredFacts.Add(f.FactType, f); } } else { // Handle a census fact on a family. if (Properties.GeneralSettings.Default.OnlyCensusParents) { if (Husband != null && Husband.IsAlive(f.FactDate)) { Husband.AddFact(f); } if (Wife != null && Wife.IsAlive(f.FactDate)) { Wife.AddFact(f); } } else { // all members of the family who are alive get the census fact foreach (Individual person in Members) { if (person.IsAlive(f.FactDate)) { person.AddFact(f); } } } } preferredFact = false; } }
// Use this for initialization void Start() { Add(new int[] { 1, 2, 3, 1 }); Add(new int[] { 1, 2, 3, 1, 4 }); Add(1, 1, 1); int[] a1 = new int[] { 1, 3 }; int[] a2 = a1; //a1[0] = 2; a1 = new int[] { 2, 3 }; print(a2[0]); int a = 1; int[] arr = new int[] { 1 }; Fun(a, arr); print(a); print(arr[0]); int result; bool state = int.TryParse("250", out result); print(state); print(result); string s1 = "八戒"; string s2 = "八戒"; string s3 = new string(new char[] { '八', '戒' }); string s4 = new string(new char[] { '八', '戒' }); print(object.ReferenceEquals(s1, s2)); print(object.ReferenceEquals(s3, s4)); //这里用到枚举叠加 GetPersonType(PersonStyle.Builty | PersonStyle.Good); Wife wife1 = new Wife(); Wife wife2 = new Wife("Min"); Wife wife3 = new Wife("Min", 18); Dictionary <int, string> user = new Dictionary <int, string>(); Direct dir = new Direct(10); }
public IActionResult WifeInfo(int Wid) { //int id = wife.Id; Wife wife = _context.Wives.Where(b => b.Id == Wid).FirstOrDefault(); Disease disease = _context.diseases.Where(d => d.WifeID == Wid).FirstOrDefault(); if (disease != null) { wife.disease = disease; } Work work = _context.works.Where(w => w.WifeID == Wid).FirstOrDefault(); if (work != null) { wife.work = work; } ViewBag.Name = TempData.Peek("Name").ToString(); return(View(wife)); }
// Use this for initialization void Start() { WifeRage = GameObject.Find("Wife").gameObject.GetComponent <Wife>(); RageSlider = this.gameObject.GetComponent <Slider>(); }
public Family(XmlNode node, IProgress <string> outputText) : this(string.Empty) { if (node != null) { XmlNode eHusband = node.SelectSingleNode("HUSB"); XmlNode eWife = node.SelectSingleNode("WIFE"); FamilyID = node.Attributes["ID"].Value; string husbandID = eHusband?.Attributes["REF"]?.Value; string wifeID = eWife?.Attributes["REF"]?.Value; Husband = ft.GetIndividual(husbandID); Wife = ft.GetIndividual(wifeID); if (Husband != null && Wife != null) { Wife.MarriedName = Husband.Surname; } if (Husband != null) { Husband.FamiliesAsSpouse.Add(this); } if (Wife != null) { Wife.FamiliesAsSpouse.Add(this); } // now iterate through child elements of eChildren // finding all individuals XmlNodeList list = node.SelectNodes("CHIL"); foreach (XmlNode n in list) { if (n.Attributes["REF"] != null) { Individual child = ft.GetIndividual(n.Attributes["REF"].Value); if (child != null) { XmlNode fatherNode = n.SelectSingleNode("_FREL"); XmlNode motherNode = n.SelectSingleNode("_MREL"); var father = ParentalRelationship.GetRelationshipType(fatherNode); var mother = ParentalRelationship.GetRelationshipType(motherNode); Children.Add(child); var parent = new ParentalRelationship(this, father, mother); child.FamiliesAsChild.Add(parent); AddParentAndChildrenFacts(child, Husband, father); AddParentAndChildrenFacts(child, Wife, mother); } else { outputText.Report($"Child not found in family: {FamilyRef}\n"); } } else { outputText.Report($"Child without a reference found in family: {FamilyRef}\n"); } } AddFacts(node, Fact.ANNULMENT, outputText); AddFacts(node, Fact.DIVORCE, outputText); AddFacts(node, Fact.DIVORCE_FILED, outputText); AddFacts(node, Fact.ENGAGEMENT, outputText); AddFacts(node, Fact.MARRIAGE, outputText); AddFacts(node, Fact.MARRIAGE_BANN, outputText); AddFacts(node, Fact.MARR_CONTRACT, outputText); AddFacts(node, Fact.MARR_LICENSE, outputText); AddFacts(node, Fact.MARR_SETTLEMENT, outputText); AddFacts(node, Fact.SEPARATION, outputText); AddFacts(node, Fact.CENSUS, outputText); AddFacts(node, Fact.CUSTOM_EVENT, outputText); AddFacts(node, Fact.CUSTOM_FACT, outputText); AddFacts(node, Fact.REFERENCE, outputText); AddFacts(node, Fact.SEALED_TO_SPOUSE, outputText); AddFacts(node, Fact.UNKNOWN, outputText); //TODO: need to think about family facts having AGE tags in GEDCOM if (HasGoodChildrenStatus) { CheckChildrenStatusCounts(); } if (MarriageDate.IsKnown && !MarriageDate.Overlaps(FactDate.SAME_SEX_MARRIAGE)) // check for wrongly set gender only if pre-dates same sex marriages { if (Husband != null && !Husband.IsMale) { Husband.QuestionGender(this, true); } if (Wife != null && Wife.IsMale) { Wife.QuestionGender(this, false); } } Children.ToList().Sort(new BirthDateComparer()); } }
void AddFacts(XmlNode node, string factType, IProgress <string> outputText) { XmlNodeList list = node.SelectNodes(factType); bool preferredFact = true; foreach (XmlNode n in list) { try { Fact f = new Fact(n, this, preferredFact, outputText); f.Location.FTAnalyzerCreated = false; if (!f.Location.IsValidLatLong) { outputText.Report($"Found problem with Lat/Long for Location '{f.Location}' in facts for {FamilyID}: {FamilyName}"); } if (string.IsNullOrEmpty(f.Comment) && Husband != null && Wife != null && f.IsMarriageFact) { string description = Fact.GetFactTypeDescription(factType); f.Comment = $"{description} of {Husband.Name} and {Wife.Name}"; } if (f.FactType != Fact.CENSUS) { Facts.Add(f); if (!_preferredFacts.ContainsKey(f.FactType)) { _preferredFacts.Add(f.FactType, f); } } else { // Handle a census fact on a family. if (GeneralSettings.Default.OnlyCensusParents) { if (Husband != null && Husband.IsAlive(f.FactDate)) { Husband.AddFact(f); } if (Wife != null && Wife.IsAlive(f.FactDate)) { Wife.AddFact(f); } } else { // all members of the family who are alive get the census fact foreach (Individual person in Members.Where(p => p.IsAlive(f.FactDate))) { person.AddFact(f); } } } } catch (InvalidXMLFactException ex) { outputText.Report($"Error with Family : {FamilyID}\n Invalid fact : {ex.Message}"); } catch (TextFactDateException te) { if (te.Message == "UNMARRIED" || te.Message == "NEVER MARRIED" || te.Message == "NOT MARRIED") { Fact f = new Fact(string.Empty, Fact.UNMARRIED, FactDate.UNKNOWN_DATE, FactLocation.UNKNOWN_LOCATION, string.Empty, true, true); Husband?.AddFact(f); Wife?.AddFact(f); Facts.Add(f); } } preferredFact = false; } }
public ThisPoorGuy(decimal funds, Store store) : base(funds, store) { Brain = new Brain(); Wife = new Wife(this); }
internal Wife CreateWife(Wife newWife) { return(_repo.CreateWife(newWife)); }
public IActionResult Edit(string Field) { int Bid = (int)TempData.Peek("BenId"); string url = "~/" + Field + "/Edit/"; TempData["F"] = Field; if (Field.Equals("Beneficiars")) { var O = _context.Beneficiars.Where(b => b.Id == Bid).FirstOrDefault(); url += O.Id; } else if (Field.Equals("Wives")) { Wife wife = _context.Wives.Where(b => b.BeneficiarID == Bid).FirstOrDefault(); if (wife == null) { return(RedirectToAction("Notfound", "Home")); } //CreateModel model = new CreateModel(); //model.wife = wife; //int wid = wife.Id; //Disease disease = _context.diseases.Where(d => d.WifeID == wid).FirstOrDefault(); //if (disease != null) model.disease = disease; //Work work = _context.works.Where(w => w.WifeID == wid).FirstOrDefault(); //if (work != null) model.work = work; //string d = model.disease.DiseaseType; //string w = model.work.TypeOfWork; //model.disease = new Disease(); //model.wife.work = new Work(); //TempData.Put<CreateModel>("wife", model); int Wid = wife.Id; return(RedirectToAction("WifeInfo", "Home", new { Wid })); // url += O.Id; } else if (Field.Equals("Children")) { List <Child> children = _context.children.Where(b => b.BeneficiarID == Bid).ToList(); if (children.Count() == 0) { return(RedirectToAction("Notfound", "Home")); } //foreach (Child c in children) { // Disease disease = _context.diseases.Where(d => d.ChildID == c.Id).FirstOrDefault(); // if (disease != null) c.disease = disease; // Work work = _context.works.Where(w => w.ChildID == c.Id).FirstOrDefault(); // if (work != null) c.work = work; //} //var myChildren = _context.children.Include(c => c.BeneficiarID == Bid); return(RedirectToAction("ChildrenInfo", "Home", new { Bid })); //url += O.Id; } else if (Field.Equals("Diseases")) { var O = _context.diseases.Where(b => b.BeneficiarID == Bid).FirstOrDefault(); if (O == null) { return(RedirectToAction("Notfound", "Home")); } url += O.ID; } else if (Field.Equals("Addresses")) { var O = _context.addresses.Where(b => b.BeneficiarID == Bid).FirstOrDefault(); if (O == null) { return(RedirectToAction("Notfound", "Home")); } url += O.Id; } else if (Field.Equals("Loans")) { var O = _context.loans.Where(b => b.BeneficiarID == Bid).FirstOrDefault(); if (O == null) { return(RedirectToAction("Notfound", "Home")); } url += O.Id; } else if (Field.Equals("Belongings")) { var O = _context.belongings.Where(b => b.BeneficiarID == Bid).FirstOrDefault(); if (O == null) { return(RedirectToAction("Notfound", "Home")); } url += O.Id; } else if (Field.Equals("Works")) { var O = _context.works.Where(b => b.BeneficiarID == Bid).FirstOrDefault(); if (O == null) { return(RedirectToAction("Notfound", "Home")); } url += O.Id; } else if (Field.Equals("SocialHelps")) { var O = _context.socialHelps.Where(b => b.BeneficiarID == Bid).FirstOrDefault(); if (O == null) { return(RedirectToAction("Notfound", "Home")); } url += O.ID; } return(Redirect(url)); }
public async Task <IActionResult> DeleteConfirmed(int id) { var beneficiar = await _context.Beneficiars.FindAsync(id); Wife wife = _context.Wives.Where(w => w.BeneficiarID == id).FirstOrDefault(); if (wife != null) { Work w1 = _context.works.Where(w => w.WifeID == wife.Id).FirstOrDefault(); if (w1 != null) { _context.works.Remove(w1); } await _context.SaveChangesAsync(); Disease d1 = _context.diseases.Where(w => w.WifeID == wife.Id).FirstOrDefault(); if (d1 != null) { _context.diseases.Remove(d1); } await _context.SaveChangesAsync(); _context.Wives.Remove(wife); } Work w = _context.works.Where(w => w.BeneficiarID == id).FirstOrDefault(); if (w != null) { _context.works.Remove(w); } Belongings b = _context.belongings.Where(w => w.BeneficiarID == id).FirstOrDefault(); if (b != null) { _context.belongings.Remove(b); } Address a = _context.addresses.Where(w => w.BeneficiarID == id).FirstOrDefault(); if (a != null) { _context.addresses.Remove(a); } Loans l = _context.loans.Where(w => w.BeneficiarID == id).FirstOrDefault(); if (l != null) { _context.loans.Remove(l); } SocialHelp s = _context.socialHelps.Where(w => w.BeneficiarID == id).FirstOrDefault(); if (s != null) { _context.socialHelps.Remove(s); } Disease d = _context.diseases.Where(w => w.BeneficiarID == id).FirstOrDefault(); if (d != null) { _context.diseases.Remove(d); } List <Child> children = _context.children.Where(c => c.BeneficiarID == id).ToList(); foreach (Child c in children) { Work w2 = _context.works.Where(w => w.ChildID == c.Id).FirstOrDefault(); if (w2 != null) { _context.works.Remove(w2); } Disease d2 = _context.diseases.Where(w => w.ChildID == c.Id).FirstOrDefault(); if (d2 != null) { _context.diseases.Remove(d2); } await _context.SaveChangesAsync(); _context.children.Remove(c); } await _context.SaveChangesAsync(); _context.Beneficiars.Remove(beneficiar); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }