private void TryAdd(User aUser) { using (BlueBuilderDBContext context = new BlueBuilderDBContext()) { UserAndEntityConverter translator = new UserAndEntityConverter(); UserEntity anEntity = translator.ToEntity(aUser); context.Users.Add(anEntity); context.SaveChanges(); } }
private void TryModify(User modified) { UserAndEntityConverter translator = new UserAndEntityConverter(); using (BlueBuilderDBContext context = new BlueBuilderDBContext()) { UserEntity record = translator.ToEntity(modified); context.Users.Attach(record); context.Entry(record).State = EntityState.Modified; context.SaveChanges(); } }
public BlueprintEntity BlueprintToEntiy(IBlueprint toConvert) { UserAndEntityConverter userEntityConverter = new UserAndEntityConverter(); BlueprintEntity conversion = new BlueprintEntity() { Name = toConvert.Name, Length = toConvert.Length, Width = toConvert.Width, Owner = userEntityConverter.ToEntity(toConvert.Owner), Id = toConvert.GetId() }; return(conversion); }