Inheritance: System.Data.Objects.DataClasses.EntityObject
 /// <summary>
 /// Deprecated Method for adding a new object to the TranslationDatas EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToTranslationDatas(TranslationData translationData)
 {
     base.AddObject("TranslationDatas", translationData);
 }
Esempio n. 2
0
    /// <summary>
    /// Loads the information from the dto into the data object. Except...
    /// Does NOT load dto.Id.
    /// </summary>
    /// <param name="data"></param>
    /// <param name="dto"></param>
    public static void LoadDataFromDto(ref TranslationData data, 
                                       TranslationDto dto, 
                                       LearnLanguagesContext context)
    {
      //COPY USER INFO
      data.UserDataId = dto.UserId;
      data.UserData = EfHelper.GetUserData(dto.UserId, context);

      var currentPhraseIds = (from phrase in data.PhraseDatas
                              select phrase.Id);

      //COPY PHRASEID INFO
      //ADD NEW PHRASEDATAS IN THE DTO
      foreach (var id in dto.PhraseIds)
      {
        if (!currentPhraseIds.Contains(id))
        {
          PhraseData phraseData = EfHelper.GetPhraseData(id, context);
          data.PhraseDatas.Add(phraseData);
        }
      }

      //REMOVE PHRASEDATAS THAT ARE NOT IN DTO ANYMORE
      foreach (var phraseId in currentPhraseIds)
      {
        if (!dto.PhraseIds.Contains(phraseId))
        {
          var dataToRemove = (from phraseData in data.PhraseDatas
                              where phraseData.Id == phraseId
                              select phraseData).First();
          data.PhraseDatas.Remove(dataToRemove);
        }
      }
    }
 /// <summary>
 /// Create a new TranslationData object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="userDataId">Initial value of the UserDataId property.</param>
 public static TranslationData CreateTranslationData(global::System.Guid id, global::System.Guid userDataId)
 {
     TranslationData translationData = new TranslationData();
     translationData.Id = id;
     translationData.UserDataId = userDataId;
     return translationData;
 }
Esempio n. 4
0
    public static TranslationDto ToDto(TranslationData data)
    {
      var dto = new TranslationDto()
      {
        Id = data.Id,
        PhraseIds = (from phrase in data.PhraseDatas
                     select phrase.Id).ToList(),
        UserId = data.UserDataId,
        Username = data.UserData.Username
      };

      return dto;
    }