public DataBase() { // создание пустого списка _head = null; _tail = _head; Length = 0; }
public void Push(Share element) { if (_head == null) { // создать узел, сделать его головным _head = new ShareList { Element = element }; // этот же узел и является хвостовым _tail = _head; // следующего узла нет _head.Next = null; } else { // создать временный узел ShareList tempBL = new ShareList(); // следующий за предыдущим хвостовым узлом - это наш временный новый узел _tail.Next = tempBL; // сделать его же новым хвостовым _tail = tempBL; _tail.Element = element; // следующего узла пока нет _tail.Next = null; } ++Length; }
public Share this[int position] { get { if (position >= 0) { ShareList tempBL = _head; for (int i = 0; i < position; ++i) { // переходим к следующему узлу списка tempBL = tempBL.Next; } return(tempBL.Element); } else { return(null); } } set { if (position >= 0) { ShareList tempBL = _head; for (int i = 0; i < position; ++i) { tempBL = tempBL.Next; } tempBL.Element = value; } } }
/// <summary> /// 删除对应文件名称项 /// </summary> /// <param name="shareId"></param> private void DeleteFileItem(string shareId) { var item = ShareList.FirstOrDefault(f => f.shareId == shareId); App.Current.Dispatcher.Invoke(() => { if (item != null) { ShareList.Remove(item); } }); }
public void PopulatePresentationList() { PresentationList = new List <SharePresentation>(); ShareList.ForEach(s => PresentationList.Add(new SharePresentation() { ShareId = s.Id, Quantity = s.Quantity, SharePrice = s.SharePrice })); PresentationList.ForEach(p => p.BenchmarkWeight = BenchmarkList.Find(b => b.ShareId.Equals(p.ShareId)).Weight); PresentationList.ForEach(p => p.ShareWeight = (p.HoldingValue / GetTotalPortfolioValue() * 100)); PresentationList.ForEach(p => p.CalculateRecommendedShareMove(GetTotalPortfolioValue())); }
public async Task <IActionResult> Share([FromBody] ShareList dto) { if (dto == null) { return(BadRequest()); } try { dto.UserId = IdentityHelper.GetUserId(User); } catch (UnauthorizedAccessException) { return(Unauthorized()); } foreach (ShareUserAndPermission removedShare in dto.RemovedShares) { // Notify if (await _userService.CheckIfUserCanBeNotifiedOfListChangeAsync(dto.ListId, removedShare.UserId)) { var currentUser = await _userService.GetAsync(dto.UserId); var user = await _userService.GetAsync(removedShare.UserId); SimpleList list = await _listService.GetAsync(dto.ListId); CultureInfo.CurrentCulture = new CultureInfo(user.Language, false); var message = _localizer["RemovedShareNotification", IdentityHelper.GetUserName(User), list.Name]; var createNotificationDto = new CreateOrUpdateNotification(user.Id, dto.UserId, null, null, message); var notificationId = await _notificationService.CreateOrUpdateAsync(createNotificationDto); var pushNotification = new PushNotification { SenderImageUri = currentUser.ImageUri, UserId = user.Id, Application = "To Do Assistant", Message = message, OpenUrl = GetNotificationsPageUrl(notificationId) }; _senderService.Enqueue(pushNotification); } } await _listService.ShareAsync(dto, _shareValidator); return(NoContent()); }
protected void ShareBind(bool current = false) { if (current) { TabPlay("share"); } int pageCount = 0; List <WMUserSets> list = WMUserSets.GetList(out pageCount, 402, UserId, SharePager.CurrentPageIndex - 1, SharePager.PageSize); ShareList.DataSource = list; ShareList.DataBind(); SharePager.RecordCount = pageCount; }
public async Task ShareAsync(ShareList model, IValidator <ShareList> validator) { ValidateAndThrow(model, validator); var now = DateTime.UtcNow; var newShares = new List <ListShare>(); foreach (ShareUserAndPermission newShare in model.NewShares) { if (_listsRepository.UserHasBlockedSharing(model.ListId, model.UserId, newShare.UserId)) { continue; } newShares.Add(new ListShare { ListId = model.ListId, UserId = newShare.UserId, IsAdmin = newShare.IsAdmin, CreatedDate = now, ModifiedDate = now }); } var editedShares = model.EditedShares.Select(x => new ListShare { ListId = model.ListId, UserId = x.UserId, IsAdmin = x.IsAdmin, ModifiedDate = now }); var removedShares = model.RemovedShares.Select(x => new ListShare { ListId = model.ListId, UserId = x.UserId, IsAdmin = x.IsAdmin }); await _listsRepository.SaveSharingDetailsAsync(newShares, editedShares, removedShares); foreach (ListShare share in removedShares) { await _notificationsRepository.DeleteForUserAndListAsync(share.UserId, share.ListId); } }
public Share() { this.InitializeComponent(); SelectAllBox.Checked += (sender, e) => { ShareList.SelectAll(); }; SelectAllBox.Unchecked += (sender, e) => { ShareList.SelectedItems.Clear(); }; SelectAllBox.Click += (sender, e) => { if (!SelectAllBox.IsChecked.HasValue) { SelectAllBox.IsChecked = false; } }; }
public ShareableContent(ShareList shareInfo) { Id = shareInfo.Id; UserName = shareInfo.User.UserName; UpdateAt = shareInfo.ShareAt; if (shareInfo.Note != null) { Title = shareInfo.Note.Title; Content = shareInfo.Note.Content; LoveCount = shareInfo.Note.LoveCount; } else if (shareInfo.Plan != null) { var plan = shareInfo.Plan; if (plan.Content != null) { Title = plan.Content.Length < 10 ? plan.Content : plan.Content.Substring(0, 10); } var sb = new StringBuilder(); sb.Append("开始时间: ").Append(plan.CreateAt).Append("<br />\n"); if (plan.ExpectEndAt != default(DateTime)) { sb.Append("预计完成: ").Append(plan.ExpectEndAt).Append("<br />\n"); } sb.Append("是否完成: ").Append(plan.IsCompleted ? "是" : "否").Append("<br />\n<br />\n"); sb.Append(plan.Content); Content = sb.ToString(); LoveCount = shareInfo.Plan.LoveCount; } else { throw new InvalidProgramException("invalid share data type"); } }
public void Delete(int position) { if (position == 0) { _head = _head.Next; } else { ShareList tempBL = _head; ShareList prev = _head; for (int i = 0; i < position + 1; ++i) { if (position > 0 && i == position - 1) { prev = tempBL; } tempBL = tempBL.Next; } prev.Next = tempBL; } Length--; GC.Collect(); }
public double GetTotalPortfolioValue() { return(ShareList.Sum(s => s.Quantity * s.SharePrice) + (Portfolio.CashPennies / 100)); }