public async Task <IActionResult> Edit(int id, [Bind("ID,MembersID,ChildID")] ParentChild parentChild) { if (id != parentChild.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(parentChild); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ParentChildExists(parentChild.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ChildID"] = new SelectList(_context.Child, "ID", "FirstName", parentChild.ChildID); ViewData["MembersID"] = new SelectList(_context.Parent, "ID", "FirstName", parentChild.MembersID); return(View(parentChild)); }
public IList <SubjectObjectsTuple> Process(XElement sent, ref int directAndIndirectSpeechGlobalNumber, ObjectAllocateMethod objectAllocateMethod) { sent.ThrowIfNotSent(); var opinionMiningTuples = new List <SubjectObjectsTuple>(); ThreeSubsent.Process(sent, Language, ref directAndIndirectSpeechGlobalNumber, objectAllocateMethod) .AddRangeTo(opinionMiningTuples); if (opinionMiningTuples.AnyEx()) { return(opinionMiningTuples); } ThreeParentChild.Process(sent, Language, ref directAndIndirectSpeechGlobalNumber, objectAllocateMethod) .AddRangeTo(opinionMiningTuples); if (opinionMiningTuples.AnyEx()) { return(opinionMiningTuples); } ParentChild_DP.Process(sent, Language, ref directAndIndirectSpeechGlobalNumber, objectAllocateMethod) .AddRangeTo(opinionMiningTuples); if (opinionMiningTuples.AnyEx()) { return(opinionMiningTuples); } ParentChild.Process(sent, Language, ref directAndIndirectSpeechGlobalNumber, objectAllocateMethod) .AddRangeTo(opinionMiningTuples); if (opinionMiningTuples.AnyEx()) { return(opinionMiningTuples); } ParentChild_Desc.Process(sent, Language, ref directAndIndirectSpeechGlobalNumber, objectAllocateMethod) .AddRangeTo(opinionMiningTuples); if (opinionMiningTuples.AnyEx()) { return(opinionMiningTuples); } TwoSubsent.Process(sent, Language, ref directAndIndirectSpeechGlobalNumber, objectAllocateMethod) .AddRangeTo(opinionMiningTuples); if (opinionMiningTuples.AnyEx()) { return(opinionMiningTuples); } OneSubsent.Process(sent, Language, ref directAndIndirectSpeechGlobalNumber, objectAllocateMethod) .AddRangeTo(opinionMiningTuples); if (opinionMiningTuples.AnyEx()) { return(opinionMiningTuples); } return(opinionMiningTuples); }
public async Task <IActionResult> Create([Bind("ID,MembersID,ChildID")] ParentChild parentChild) { if (ModelState.IsValid) { _context.Add(parentChild); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ChildID"] = new SelectList(_context.Child, "ID", "FirstName", parentChild.ChildID); ViewData["MembersID"] = new SelectList(_context.Parent, "ID", "FirstName", parentChild.MembersID); return(View(parentChild)); }
// ReSharper disable once UnusedMember.Local private static ParentChild AddParentChild(KindergartenContext k) { var group = new Group { Name = "Солнышко", GroupType = Groups.Nursery, }; // k.Groups.Add(group); var child = new Child { Person = new Person { FirstName = "Иван", LastName = "Иванов", Patronymic = "Иванович", }, BirthDate = new DateTime(2014, 1, 4), Group = @group, LocationAddress = "ул. Ленина д. 12", Sex = Sex.Male, }; // k.Children.Add(child); var parent = new Parent { LocationAddress = "ул. Ленина д. 12", ResidenceAddress = "ул. Ленина д. 12", WorkAddress = "ул. Ленина д. 73", PassportIssueDate = new DateTime(1990, 04, 12), PassportIssuedBy = "ОУФМС России по р. ХХХ", PassportSeries = "0123456789", PhoneNumber = "+7 912 345 67 89", Person = new Person { FirstName = "Сергей", LastName = "Иванов", Patronymic = "Васильевич", }, }; // k.Parents.Add(parent); var parentChild = new ParentChild { Child = child, Parent = parent, ParentType = Parents.Father, }; k.ParentChildren .Add(parentChild); return(parentChild); }
public void Update(int id, ParentChild parentchild) { _service.Update(id, parentchild); }
public void Register(ParentChild parentchild) { _service.Add(parentchild); }
public void Update(int id, ParentChild entity) { _repo.Update(id, entity.ToDAL()); }
public void Add(ParentChild entity) { _repo.Add(entity.ToDAL()); }
private async void AddChild(Child child) { if (!child.IsValid()) { MessageBox.Show("Не все поля заполнены/пункты выбраны", "Внимание", MessageBoxButton.OK, MessageBoxImage.Warning); return; } var now = DateTime.Now; if (ChildAdditionDate > now) { MessageBox.Show("Ввод будущей даты добавления запрещён", "Внимание", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (child.BirthDate > ChildAdditionDate) { MessageBox.Show("Дата рождения должна быть меньше даты добавления", "Внимание", MessageBoxButton.OK, MessageBoxImage.Warning); return; } if (SelectedOther == null && SelectedMother == null && SelectedFather == null) { MessageBox.Show("Должен быть выбран хотя бы один из родителей либо иной представитель", "Некорректный выбор", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (BroughtParent == Parents.Father && SelectedFather == null || BroughtParent == Parents.Mother && SelectedMother == null || BroughtParent == Parents.Other && SelectedOther == null) { MessageBox.Show("Выберите существующего родителя"); return; } AddChildCommand.NotifyCanExecute(false); ParentChild broghtParent = null; EnterChild enterChild = null; bool needAddPayments = StartedToPayFromAdditionDate; await Task.Run(() => { string imageFileName = null; try { if (_imageUri != null) { var savePath = Path.Combine(Settings.AppFilePaths.ChildImages, CommonHelper.GetUniqueString()); imageFileName = ImageUtil.SaveImage(_imageUri, savePath); child.Person.PhotoPath = Path.GetFileName(imageFileName); } // groups and tarifs (in OnLoaded) are from other context child.GroupId = child.Group.Id; child.Group = null; child.TarifId = child.Tarif.Id; enterChild = new EnterChild { Child = child, EnterDate = ChildAdditionDate }; child.LastEnterChild = enterChild; var context = new KindergartenContext(); if (needAddPayments) { // to no debt range add if (now.Year != ChildAdditionDate.Year && now.Month != ChildAdditionDate.Month) { // 1) the first fictitious payment for start range context.MonthlyPayments.Add(new MonthlyPayment { ChildId = child.Id, PaymentDate = ChildAdditionDate, MoneyPaymentByTarif = 0, // 0 - because to make no debt }); } // 2) the second fictitious payment for end range context.MonthlyPayments.Add(new MonthlyPayment { ChildId = child.Id, PaymentDate = now, MoneyPaymentByTarif = child.Tarif.MonthlyPayment, DebtAfterPaying = InitialDebt, }); } child.Tarif = null; context.EnterChildren.Add(enterChild); if (SelectedFather != null) { var parentChild = new ParentChild { Child = child, ParentId = SelectedFather.Id, ParentType = Parents.Father }; context.ParentChildren.Add(parentChild); if (BroughtParent == Parents.Father) { broghtParent = parentChild; } } if (SelectedMother != null) { var parentChild = new ParentChild { Child = child, ParentId = SelectedMother.Id, ParentType = Parents.Mother }; context.ParentChildren.Add(parentChild); if (BroughtParent == Parents.Mother) { broghtParent = parentChild; } } if (SelectedOther != null) { var parentChild = new ParentChild { Child = child, ParentId = SelectedOther.Id, ParentType = Parents.Other, ParentTypeText = OtherParentText }; context.ParentChildren.Add(parentChild); if (BroughtParent == Parents.Other) { broghtParent = parentChild; } } context.SaveChanges(); App.Logger.Debug("Child added"); } catch { if (imageFileName != null) { File.Delete(imageFileName); } throw; } }); Pipe.SetParameter("saved_child_result", child); Pipe.SetParameter("brought_parent", broghtParent); Pipe.SetParameter("enter", enterChild); // ReSharper disable once RedundantExplicitArraySize var parents = new ParentChild[3] { new ParentChild { Parent = SelectedFather, ParentType = Parents.Father }, new ParentChild { Parent = SelectedMother, ParentType = Parents.Mother }, new ParentChild { Parent = SelectedOther, ParentType = Parents.Other } }; Pipe.SetParameter("parents", parents); AddChildCommand.NotifyCanExecute(true); Finish(); }
public static List <Student> LoadClassStudents(string file, Class cl) { List <Student> res = new List <Student>(); try { Excel.Application app = new Excel.Application(); var book = app.Workbooks.Open(file); Excel.Worksheet worksheet = (Excel.Worksheet)book.Worksheets.Item[1]; var range = worksheet.UsedRange; int rowCount = range.Rows.Count; int colCount = range.Columns.Count; for (int i = 4; i <= rowCount; i++) { Student cur = LoadStudent(range, i); if (cur == null) { break; } res.Add(cur); Student answ = StationManager.DataStorage.SaveStudent(cur); if (answ == null) { MessageBox.Show( $"Ученик {cur.SurnameNamePatr} не добавлен. Возможно он уже занесён в базу. Проверьте его наличие в базе.", "Ошибка добавления", MessageBoxButtons.OK, MessageBoxIcon.Error); //TODO edit window } else if (cur.MobileNumbers.Count != 0) { StationManager.DataStorage.AddMobileNumber(answ, cur.MobileNumbers[0]); } Parent mother = LoadParent(range, i, 1); if (mother != null) { Parent parentAnsw = StationManager.DataStorage.ParentExists(mother); if (parentAnsw != null) { var dialogRes = MessageBox.Show( $"Родитель {mother.SurnameNamePatr}, {mother.Birthday?.ToString("dd/MMM/yyyy")} уже существует." + $"Добавить как родителя ребёнка {cur.SurnameNamePatr}?", "Ошибка добавления", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error); //TODO edit window if (dialogRes == DialogResult.Yes) { if (!String.IsNullOrEmpty(parentAnsw.Id) && !String.IsNullOrEmpty(cur.Id)) { ParentChild pc = new ParentChild(); pc.Parent = parentAnsw; pc.Child = cur; pc.Role = "mother"; StationManager.DataStorage.SaveParentChild(pc); } } } else { StationManager.DataStorage.SaveParent(mother); if (mother.MobileNumbers.Count != 0) { StationManager.DataStorage.AddMobileNumber(mother, mother.MobileNumbers[0]); } if (!String.IsNullOrEmpty(mother.Id) && !String.IsNullOrEmpty(cur.Id)) { ParentChild pc = new ParentChild(); pc.Parent = mother; pc.Child = cur; pc.Role = "mother"; StationManager.DataStorage.SaveParentChild(pc); } } } Parent father = LoadParent(range, i, 2); if (father != null) { Parent parentAnsw = StationManager.DataStorage.ParentExists(father); if (parentAnsw != null) { var dialogRes = MessageBox.Show( $"Родитель {father.SurnameNamePatr}, {father.Birthday?.ToString("dd/MMM/yyyy")} уже существует." + $"Добавить как родителя ребёнка {cur.SurnameNamePatr}?", "Ошибка добавления", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error); //TODO edit window if (dialogRes == DialogResult.Yes) { if (!String.IsNullOrEmpty(parentAnsw.Id) && !String.IsNullOrEmpty(cur.Id)) { ParentChild pc = new ParentChild(); pc.Parent = parentAnsw; pc.Child = cur; pc.Role = "father"; StationManager.DataStorage.SaveParentChild(pc); } } } else { StationManager.DataStorage.SaveParent(father); if (father.MobileNumbers.Count != 0) { StationManager.DataStorage.AddMobileNumber(father, father.MobileNumbers[0]); } if (!String.IsNullOrEmpty(father.Id) && !String.IsNullOrEmpty(cur.Id)) { ParentChild pc = new ParentChild(); pc.Parent = father; pc.Child = cur; pc.Role = "father"; StationManager.DataStorage.SaveParentChild(pc); } } } Parent trustee1 = LoadParent(range, i, 3); if (trustee1 != null) { Parent parentAnsw = StationManager.DataStorage.ParentExists(trustee1); if (parentAnsw != null) { var dialogRes = MessageBox.Show( $"Родитель {trustee1.SurnameNamePatr}, {trustee1.Birthday?.ToString("dd/MMM/yyyy")} уже существует." + $"Добавить как родителя ребёнка {cur.SurnameNamePatr}?", "Ошибка добавления", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error); //TODO edit window if (dialogRes == DialogResult.Yes) { if (!String.IsNullOrEmpty(parentAnsw.Id) && !String.IsNullOrEmpty(cur.Id)) { ParentChild pc = new ParentChild(); pc.Parent = parentAnsw; pc.Child = cur; pc.Role = "trustee"; var val = range.Range["BP" + i]?.Value2; pc.Trustee = val != null; val = range.Range["BQ" + i]?.Value2; if (val != null) { pc.Relation = val.ToString(); } StationManager.DataStorage.SaveParentChild(pc); } } } else { StationManager.DataStorage.SaveParent(trustee1); if (trustee1.MobileNumbers.Count != 0) { StationManager.DataStorage.AddMobileNumber(trustee1, trustee1.MobileNumbers[0]); } if (!String.IsNullOrEmpty(trustee1.Id) && !String.IsNullOrEmpty(cur.Id)) { ParentChild pc = new ParentChild(); pc.Parent = trustee1; pc.Child = cur; pc.Role = "trustee"; var val = range.Range["BP" + i]?.Value2; pc.Trustee = val != null; val = range.Range["BQ" + i]?.Value2; if (val != null) { pc.Relation = val.ToString(); } StationManager.DataStorage.SaveParentChild(pc); } } } Parent trustee2 = LoadParent(range, i, 4); if (trustee2 != null) { Parent parentAnsw = StationManager.DataStorage.ParentExists(trustee2); if (parentAnsw != null) { var dialogRes = MessageBox.Show( $"Родитель {trustee2.SurnameNamePatr}, {trustee2.Birthday?.ToString("dd/MMM/yyyy")} уже существует." + $"Добавить как родителя ребёнка {cur.SurnameNamePatr}?", "Ошибка добавления", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Error); //TODO edit window if (dialogRes == DialogResult.Yes) { if (!String.IsNullOrEmpty(parentAnsw.Id) && !String.IsNullOrEmpty(cur.Id)) { ParentChild pc = new ParentChild(); pc.Parent = parentAnsw; pc.Child = cur; pc.Role = "trustee"; var val = range.Range["CH" + i]?.Value2; pc.Trustee = val != null; val = range.Range["CI" + i]?.Value2; if (val != null) { pc.Relation = val.ToString(); } StationManager.DataStorage.SaveParentChild(pc); } } } else { StationManager.DataStorage.SaveParent(trustee2); if (trustee2.MobileNumbers.Count != 0) { StationManager.DataStorage.AddMobileNumber(trustee2, trustee2.MobileNumbers[0]); } if (!String.IsNullOrEmpty(trustee2.Id) && !String.IsNullOrEmpty(cur.Id)) { ParentChild pc = new ParentChild(); pc.Parent = trustee2; pc.Child = cur; pc.Role = "trustee"; var val = range.Range["CH" + i]?.Value2; pc.Trustee = val != null; val = range.Range["CI" + i]?.Value2; if (val != null) { pc.Relation = val.ToString(); } StationManager.DataStorage.SaveParentChild(pc); } } } } book.Close(); } catch (Exception e) { MessageBox.Show("Произошла ошибка импорта. " + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(res); }
/// <summary> /// 様々な条件でBacklogの課題を検索します。 /// </summary> /// <param name="apiKey">BacklogAPIを呼び出すためのAPIKey</param> /// <param name="spaceKey">組織キー https://xxxx.backlog.jp/ のxxxの部分</param> /// <param name="projectIds">プロジェクトのID</param> /// <param name="issueTypeIds">種別のID</param> /// <param name="categoryIds">カテゴリーのID</param> /// <param name="versionIds">発生バージョンのID</param> /// <param name="milestoneIds">マイルストーンのID</param> /// <param name="statusIds">状態のID</param> /// <param name="priorityIds">優先度のID</param> /// <param name="assigneeIds">担当者のID</param> /// <param name="createdUserIds">登録者のID</param> /// <param name="resolutionIds">完了理由のID</param> /// <param name="parentChild">親子課題の条件 0: すべて, 1: 子課題以外, 2: 子課題, 3: 親課題でも子課題でもない課題, 4: 親課題</param> /// <param name="attachment">添付ファイルを含む場合はtrue</param> /// <param name="sharedFile">共有ファイルを含む場合はtrue</param> /// <param name="sort">課題一覧のソートに使用する属性名</param> /// <param name="order">“asc”または”desc” 指定が無い場合は”desc”</param> /// <param name="offset"></param> /// <param name="count">取得上限(1-100) 指定が無い場合は100</param> /// <param name="createdSince">登録日(yyyy-mm-dd)</param> /// <param name="createdUntil">登録日(yyyy-mm-dd)</param> /// <param name="updatedSince">更新日(yyyy-mm-dd)</param> /// <param name="updatedUntil">更新日(yyyy-mm-dd)</param> /// <param name="startDateSince">開始日(yyyy-mm-dd)</param> /// <param name="startDateUntil">開始日(yyyy-mm-dd)</param> /// <param name="dueDateSince">期限日(yyyy-mm-dd)</param> /// <param name="dueDateUntil">期限日(yyyy-mm-dd)</param> /// <param name="ids">課題のID</param> /// <param name="parentIssueIds">親課題のID</param> /// <param name="keyWord">検索キーワード</param> /// <returns></returns> public async Task <ActionResult <Issue[]> > FindByAsync( [Required] string apiKey, [Required] string spaceKey, string projectIds = "[]", string issueTypeIds = "[]", string categoryIds = "[]", string versionIds = "[]", string milestoneIds = "[]", string statusIds = "[]", string priorityIds = "[]", string assigneeIds = "[]", string createdUserIds = "[]", string resolutionIds = "[]", ParentChild parentChild = ParentChild.All, bool attachment = false, bool sharedFile = false, string sort = "created", string order = "desc", int offset = 0, int count = 100, DateTime?createdSince = null, DateTime?createdUntil = null, DateTime?updatedSince = null, DateTime?updatedUntil = null, DateTime?startDateSince = null, DateTime?startDateUntil = null, DateTime?dueDateSince = null, DateTime?dueDateUntil = null, string ids = "[]", string parentIssueIds = "[]", string keyWord = null) { if (offset < 0) { return(null); } if (count <= 0) { return(null); } var pageSize = AdjustPageSize(count); var results = new List <Issue>(); for (var i = 0; i < (int)Math.Ceiling((double)count / MaxPageSize); i++) { var currentOffset = offset + i * pageSize; var remainingSize = count - currentOffset; var currentCount = AdjustPageSize(remainingSize); var issues = await _httpClientFactory .CreateRestServiceClient <IBacklogClient>(spaceKey) .FindIssiesByAsync(apiKey, projectIds.FromJsonToIntArray(), issueTypeIds.FromJsonToIntArray(), categoryIds.FromJsonToIntArray(), versionIds.FromJsonToIntArray(), milestoneIds.FromJsonToIntArray(), statusIds.FromJsonToIntArray(), priorityIds.FromJsonToIntArray(), assigneeIds.FromJsonToIntArray(), createdUserIds.FromJsonToIntArray(), resolutionIds.FromJsonToIntArray(), (int)parentChild, attachment.ToString().ToLower(), sharedFile.ToString().ToLower(), sort, order, currentOffset, currentCount, createdSince?.ToString("yyyy-MM-dd"), createdUntil?.ToString("yyyy-MM-dd"), updatedSince?.ToString("yyyy-MM-dd"), updatedUntil?.ToString("yyyy-MM-dd"), startDateSince?.ToString("yyyy-MM-dd"), startDateUntil?.ToString("yyyy-MM-dd"), dueDateSince?.ToString("yyyy-MM-dd"), dueDateUntil?.ToString("yyyy-MM-dd"), ids.FromJsonToIntArray(), parentIssueIds.FromJsonToIntArray(), keyWord); if (issues == null || !issues.Any()) { break; } results.AddRange(issues); } return(results.ToArray()); }