public void WhenCallingChangeNote_TheTextIsUpdated() { var note = new DiaryNote(Guid.NewGuid(), "A super note"); note.ChangeText("A great note"); Assert.Equal("A great note", note.Text); }
public void Intialize(DiaryNote owner, string filepath, LogTree logTree, string text) { ownerNote_ = owner; name = Path.GetFileName(filepath); filepath_ = filepath; logTree_ = logTree; GetComponentInChildren <Text>().text = text; graphic_ = GetComponent <Button>().targetGraphic; if (logTree_ == null) { graphic_.color = ColorManager.MakeAlpha(graphic_.color, 0.6f); } }
public async Task <ActionResult> DiaryNoteQueue([FromBody] DiaryNote diaryNote) { var eventMsg = _mapper.Map <SaveDiaryNoteEvent>(diaryNote); eventMsg.RequestID = Guid.NewGuid(); try { _eventBus.PublishSaveDiaryNoteEvent(EventBusConsts.DiaryNoteQueue, eventMsg); } catch (Exception) { } return(Accepted()); }
private void Create() { var note = new DiaryNote(); Console.WriteLine("Input date"); note.Date = DateTime.Parse(Console.ReadLine()); Console.WriteLine("Input pressure"); note.Pressure = int.Parse(Console.ReadLine()); Console.WriteLine("Input cloudness"); note.Cloudness = (CloudnessEnum)Enum.Parse(typeof(CloudnessEnum), Console.ReadLine()); Console.WriteLine("Input wind direction"); note.WindDirection = Console.ReadLine(); _client.ProcessRequest("/api/diarynote/", HttpMethod.Post, JsonSerializer.Serialize(note)); }
public void OpenDiary(bool isActive = true) { // ノートを開いていなければできない if (MainTabGroup.Count == 0) { return; } DiaryNote diaryNote = MainTabGroup.ExistDiaryNote; if (diaryNote == null) { TabButton tab = Instantiate(TabButtonPrefab.gameObject, TabParent.transform).GetComponent <TabButton>(); diaryNote = Instantiate(DiaryNotePrefab.gameObject, NoteParent.transform).GetComponent <DiaryNote>(); MainTabGroup.OnTabCreated(tab); diaryNote.LoadDiary(tab); } diaryNote.IsActive = isActive; FileMenu.Close(); }
public async Task <ActionResult <IEnumerable <DiaryNote> > > Create([FromBody] DiaryNote diaryNote) { await _repository.Create(diaryNote); return(Ok()); }
public ActionResult Post(DiaryNote note) { _repository.Create(note); return(Ok(note)); }
public ActionResult Put(DiaryNote note) { _repository.Update(note); return(Ok(note)); }
public void WhenPassingTextThroughCtor_TheTextIsReflected() { var note = new DiaryNote(Guid.NewGuid(), "A super note"); Assert.Equal("A super note", note.Text); }
private void AssignNote(IList <Deal> deals, UnitOfWork unit) { string code = deals.First().Code; DiaryNote note = null; note = unit.DiaryNoteRepository.Query <DiaryNote>(n => n.Code == code && n.Close == null, new string[] { "NotePositions.Deal" }).SingleOrDefault(); foreach (Deal deal in deals) { if (note == null) { note = new DiaryNote() { Code = code }; unit.DiaryNoteRepository.Create(note); } if (note.Open == null) { note.Open = deal.DateTime; note.NoteType = deal.OrderOperation == OrderOperationEnum.Buy ? NoteType.Long : NoteType.Short; } int posCount = deal.Count; note.NotePositions.Add(new NotePosition() { Deal = deal, Count = posCount }); //размер позиции note.Count = note.NoteType == NoteType.Long ? note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Buy).Sum(p => p.Count) : note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Sell).Sum(p => p.Count); int overFlow = note.NoteType == NoteType.Long ? note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Sell).Sum(p => p.Count) - note.Count : note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Buy).Sum(p => p.Count) - note.Count; //переполнение if (overFlow > 0) { note.NotePositions.Last().Count -= overFlow; } if (note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Buy).Sum(p => p.Count) == note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Sell).Sum(p => p.Count)) { note.Close = deal.DateTime; decimal openPrice = note.NoteType == NoteType.Long ? note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Buy).Sum(p => p.Deal.Price * p.Count) / note.Count : note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Sell).Sum(p => p.Deal.Price * p.Count) / note.Count; decimal closePrice = note.NoteType == NoteType.Long ? note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Sell).Sum(p => p.Deal.Price * p.Count) / note.Count : note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Buy).Sum(p => p.Deal.Price * p.Count) / note.Count; note.OpenPrice = openPrice; note.ClosePrice = closePrice; int lotSize = unit.SecurityRepository.Query <Security>(s => s.Code == code, null).Single().LotSize; note.OpenValue = note.NoteType == NoteType.Long ? note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Buy).Sum(p => p.Deal.Price * p.Count * lotSize) : note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Sell).Sum(p => p.Deal.Price * p.Count * lotSize); note.CloseValue = note.NoteType == NoteType.Long ? note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Sell).Sum(p => p.Deal.Price * p.Count * lotSize) : note.NotePositions.Where(p => p.Deal.OrderOperation == OrderOperationEnum.Buy).Sum(p => p.Deal.Price * p.Count * lotSize); //create new note note = null; } if (overFlow > 0) { note = new DiaryNote() { Code = code }; unit.DiaryNoteRepository.Create(note); note.Open = deal.DateTime; note.NoteType = deal.OrderOperation == OrderOperationEnum.Buy ? NoteType.Long : NoteType.Short; note.NotePositions.Add(new NotePosition() { Deal = deal, Count = overFlow }); } deal.Processed = true; } }
public async Task Create(DiaryNote diaryNote) { await _context.DiaryNotes.InsertOneAsync(diaryNote); }