public void SetUp() { _serverUpdateStream = new Subject <Either <FullUpdate, DeltaUpdate> >(); _dictionaryModificationStream = _serverUpdateStream .Select(either => { if (either.IsLeft) { return(DictionaryModification.Replace(either.Left.Values["key"], (Update)either.Left)); } else { return(DictionaryModification.Upset(either.Right.Values["key"], (Update)either.Right)); } }); _observableDictionary = _dictionaryModificationStream.ToObservableDictionary((key, existing, update) => { var fullUpdate = new FullUpdate(key) { Values = new Dictionary <string, string>(existing.Values) }; foreach (var kvp in update) { fullUpdate.Values[kvp.Key] = kvp.Value; } return(fullUpdate); }); }
public async Task <Message> PutDic(string id, [FromBody] DictionaryModification dictionaryModification) { if (dictionaryModification == null) { return(Message.Fail()); } var dbitem = await _dictionaryRepository.GetSingleAsync(x => x.DictionaryId == id); if (dbitem == null) { return(Message.NotFound()); } dictionaryModification.DictionaryId = id; _mapper.Map(dictionaryModification, dbitem); _dictionaryRepository.Update(dbitem); if (!await _unitOfWork.SaveAsync()) { return(Message.ServerError()); } return(Message.Ok()); }