Inheritance: System.Data.Objects.DataClasses.EntityObject
 /// <summary>
 /// Create a new LanguageData object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="text">Initial value of the Text property.</param>
 /// <param name="userDataId">Initial value of the UserDataId property.</param>
 public static LanguageData CreateLanguageData(global::System.Guid id, global::System.String text, global::System.Guid userDataId)
 {
     LanguageData languageData = new LanguageData();
     languageData.Id = id;
     languageData.Text = text;
     languageData.UserDataId = userDataId;
     return languageData;
 }
Example #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 LanguageData data,
                                       LanguageDto dto,
                                       LearnLanguagesContext context)
    {
      //USER INFO
      data.UserDataId = dto.UserId;
      data.UserData = EfHelper.GetUserData(dto.UserId, context);

      //MAKE SURE USERDATA USERNAME MATCHES DTO.USERNAME
      if (data.UserData.Username != dto.Username)
        throw new Exceptions.UsernameAndUserIdDoNotMatchException(dto.Username, dto.UserId);

      //TEXT
      data.Text = dto.Text;
    }
 /// <summary>
 /// Deprecated Method for adding a new object to the LanguageDatas EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToLanguageDatas(LanguageData languageData)
 {
     base.AddObject("LanguageDatas", languageData);
 }
Example #4
0
    public static LanguageDto ToDto(LanguageData data)
    {
      var dto = new LanguageDto()
      {
        Id = data.Id,
        Text = data.Text,
        UserId = data.UserDataId,
        Username = data.UserData.Username
      };

      return dto;
    }