public void Divorse(Repository <Family> familyRepo) { var female = FemaleHead; var male = MaleHead; // no longer married MarriageDate = new Date(); MaleHead = null; // add the people to female.ExSpouses.Add(male); male.ExSpouses.Add(female); // unlink the persons female.Spouse = null; male.Spouse = null; female.MaritalStatus = MaritalStatus.Divorced; male.MaritalStatus = MaritalStatus.Divorced; // create the male's new family object male.Family.RemovePerson(male); male.Family = new Family() { Household = Household, MaleHead = male, FemaleHead = null }; male.Family.Persons.Add(male); // add the family to the repository familyRepo.AddNew(male.Family); // and add them into the household as a separate unit Household?.Families.Add(male.Family); }
public void LoadData() { var data = new Repository <LandUse>(); data.LoadData(); using (var reader = new CsvReader(LUFileLocation, true)) { while (reader.LoadLine(out int columns)) { // make sure the line has enough data if (columns > 4) { reader.Get(out int zoneNumber, 0); reader.Get(out float residential, 1); reader.Get(out float commericial, 2); reader.Get(out float open, 3); reader.Get(out float industry, 4); // industrial data.AddNew(zoneNumber, new LandUse(zoneNumber, residential, commericial, open, industry)); } } } _Data = data; Loaded = true; }
protected void AddNew() { With.Transaction(delegate { Repository <T> .AddNew(); } ); }
protected virtual T CreateNew() { T entity = default(T); With.Transaction(delegate { entity = Repository <T> .AddNew(); }); return(entity); }
public ActionResult Create(FertilityModel fertilityModel) { Repository repository = new Repository(); try { repository.AddNew(fertilityModel); } catch { ViewBag.ValidationMessage = "Something went wrong with the validation of this object. Please correct and try again."; return(View(fertilityModel)); } return(RedirectToAction("Index")); }
private int AddHouseholdToRepositories(Household household, Repository <Household> householdRepository, Repository <Family> familyRepository, Repository <Person> personRepo) { int persons = 0; foreach (var family in household.Families) { foreach (var person in family.Persons) { personRepo.AddNew(person); persons++; } familyRepository.AddNew(family); } householdRepository.AddNew(household); return(persons); }
private static void AddMotherAndBabyToNewFamily(Repository <Family> families, Person mother, Person baby, Family originalFamily) { // Baby family is setup later to reflect the mother's family Family newFamily = new Family(); newFamily.Persons.Add(mother); newFamily.Persons.Add(baby); var household = originalFamily.Household; household?.Families.Add(newFamily); newFamily.Household = household; originalFamily.Persons.Remove(mother); mother.Family = newFamily; baby.Family = newFamily; newFamily.FemaleHead = mother; families.AddNew(newFamily); }
private void Marry(Person male, Person female, Repository <Family> families) { male.MaritalStatus = MaritalStatus.Married; female.MaritalStatus = MaritalStatus.Married; male.Spouse = female; female.Spouse = male; // if the female is a family head, add the male to her family // otherwise add the female to the male family // if they are both not family heads, create a new family // add it to the male's household if (female.Family.FemaleHead == female) { male.Family.RemovePerson(male); male.Family = female.Family; female.Family.Persons.Add(male); female.Family.MaleHead = male; } else if (male.Family.MaleHead == male) { female.Family.RemovePerson(female); female.Family = male.Family; male.Family.Persons.Add(female); male.Family.FemaleHead = female; } else { var f = new Family { FemaleHead = female, MaleHead = male }; f.Persons.Add(female); f.Persons.Add(male); f.Household = male.Family.Household; f.Household?.Families.Add(f); male.Family.RemovePerson(male); female.Family.RemovePerson(female); male.Family = f; female.Family = f; families.AddNew(f); } Interlocked.Increment(ref MarriagesInYear); }
public virtual void TestAddNew() { T t = default(T); //2. Save it With.Transaction(delegate { t = Repository <T> .AddNew(); BeforeSave(t); }); //3. Check id exists object idT = Repository <T> .GetId(t); Assert.IsNotNull(idT); //3b. AfterSave(t); //4. Remove it from repository Repository <T> .Detach(t); //5.Reload it T loadedT = default(T); using (UnitOfWorkController.Start()) { loadedT = Repository <T> .Get(idT); } //6. Check Details object idLoadedT = Repository <T> .GetId(loadedT); Assert.IsNotNull(loadedT); Assert.AreEqual(idT, idLoadedT); AfterEvictAndReload(t, loadedT); //Assert.AreEqual(a.Name, loadedA.Name); }
public int 货品信息_AddNew(货品信息EditModel model) { using (var context = new BDKRContext()) { var r = new Repository<货品信息>(context); var n = new 货品信息 { 单位 = model.单位, 名称 = model.货品名称, 备注 = model.附加说明, 拼音 = UtilHelper.PinYin(model.货品名称), 是否菜品 = false, 编码 = model.编码, 规格 = model.规格型号, 货品类别编码 = model.货品类别 }; //TODO:未考虑价格因素 return r.AddNew(n, t => t.编码 == model.编码); } }
public int 货品类别_AddNew(货品类别EditModel model) { using (var context = new BDKRContext()) { var r = new Repository<货品类别>(context); var n = new 货品类别 { 编码 = model.编码, 名称 = model.类别名称, 备注 = model.备注信息 }; return r.AddNew(n, t => t.编码 == model.编码); } }
public void 门店信息_AddNew(门店EditModel model) { using (var context = new BDKRContext()) { var r = new Repository<门店信息>(context); var n = new 门店信息 { 名称 = model.门店名称, 地址 = model.门店地址, 备注 = model.附加说明, 店长 = model.店长, 编码 = model.编码, 联系电话 = model.联系电话 }; r.AddNew(n, t => t.编码 == model.编码); } }
public void Divorse(Repository<Family> familyRepo) { var female = FemaleHead; var male = MaleHead; // no longer married MarriageDate = new Date(); MaleHead = null; // add the people to female.ExSpouses.Add(male); male.ExSpouses.Add(female); // unlink the persons female.Spouse = null; male.Spouse = null; female.MaritalStatus = MaritalStatus.Divorced; male.MaritalStatus = MaritalStatus.Divorced; // create the male's new family object male.Family.RemovePerson(male); male.Family = new Family() { Household = Household, MaleHead = male, FemaleHead = null }; male.Family.Persons.Add(male); // add the family to the repository familyRepo.AddNew(male.Family); // and add them into the household as a separate unit Household?.Families.Add(male.Family); }
private static void AddMotherAndBabyToNewFamily(Repository<Family> families, Person mother, Person baby, Family originalFamily) { // Baby family is setup later to reflect the mother's family Family newFamily = new Family(); newFamily.Persons.Add(mother); newFamily.Persons.Add(baby); var household = originalFamily.Household; household?.Families.Add(newFamily); newFamily.Household = household; originalFamily.Persons.Remove(mother); mother.Family = newFamily; baby.Family = newFamily; newFamily.FemaleHead = mother; families.AddNew(newFamily); }
public void 员工信息_AddNew(员工信息EditModel model) { using (var context = new BDKRContext()) { var r = new Repository<员工信息>(context); var n = new 员工信息 { 入职日期 = model.入职日期, 姓名 = model.员工姓名, 工号 = model.工号, 当前基本工资 = model.当前基本工资, 拼音 = UtilHelper.PinYin(model.员工姓名), 编码 = model.编码, 职位 = model.职位, 联系电话 = model.联系电话, 身份证号 = model.身份证号, 门店编码 = model.门店编码, 附加说明 = model.附加说明 }; r.AddNew(n, t => t.编码 == model.编码); } }
public int 菜品信息_AddNew(菜品信息EditModel model) { int _count = 0; using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required)) { using (var context = new BDKRContext()) { var r = new Repository<货品信息>(context); var e = r.GetSingle(t => t.编码 == model.编码); if (null != e) throw new Exception("菜品信息当前已存在"); e = new 货品信息 { 单位 = model.单位, 名称 = model.菜品名称, 备注 = model.附加说明, 拼音 = UtilHelper.PinYin(model.菜品名称), 是否菜品 = true, 编码 = model.编码, 规格 = model.规格, 货品类别编码 = model.菜品类别 }; if (model.当前销售价格 > 0) { var cj = new 销售价格表 { 价格 = model.当前销售价格, 创建时间 = DateTime.Now, 编码 = 销售价格_GetNewCode(), 货品信息编码 = model.编码, 附加说明 = "" }; var _jg = new Repository<销售价格表>(context); _jg.AddNew(cj); } _count = r.AddNew(e); if (model.Details != null && model.Details.Count > 0) { var _bcode = 货品BOM_GetNewCode(); } } ts.Complete(); } return _count; }
private int AddHouseholdToRepositories(Household household, Repository<Household> householdRepository, Repository<Family> familyRepository, Repository<Person> personRepo) { int persons = 0; foreach (var family in household.Families) { foreach (var person in family.Persons) { personRepo.AddNew(person); persons++; } familyRepository.AddNew(family); } householdRepository.AddNew(household); return persons; }